Ch. 2 - Lecture4 - Variables, Assignements & Primitive Types
Ch. 2 - Lecture4 - Variables, Assignements & Primitive Types
Example:
use the int type for a variable storing integer values
A variable declaration
=> reserve portion of memory large enough to hold the value
Variable declaration
A variable
must be declared before using it by specifying
The variable’s name
int total;
int count, temp, result;
See PianoKeys.java
Assignment
An assignment statement
Changes the value of a variable
See Geometry.java
Sample programs
/* Input: Geometry.JAVA */
Characters include
Uppercase, lowercase letters; punctuation ; etc..
Boolean type
Declaration
Example: boolean flag = true;