CC 102 - Fundamental Programming Lecture 3
CC 102 - Fundamental Programming Lecture 3
Review
✓ The main method It is required and you will see it in every Java
main() program
System.out.println("Hello World");
Java Variables
Variables are ❑String - stores text, such as "Hello". String values
containers for are surrounded by double quotes
storing data ❑int - stores integers (whole numbers), without
values. decimals, such as 123 or -123
❑float - stores floating point numbers, with decimals,
such as 19.99 or -19.99
different types ❑char - stores single characters, such as 'a' or 'B'.
of variables Char values are surrounded by single quotes
❑boolean - stores values with two states: true or
false
Java Variables declarations
To create a variable, Example
you must specify the Create a variable called name of
type and assign it a type String and assign it the value "John":
value:
int num = 7 ;
num = 3;