This document discusses basic data storage in programming, including constants, variables, primitive data types, default values, possible values, variable names, and samples. It defines constants as data that never changes, variables as storage places for potentially changeable data, and primitive data types like boolean, byte, char, String, short, int, long, float, and double. It also covers initializing variables, default values for each data type, possible value ranges, naming conventions for variables, and examples of declaring different variable types.
7. Default Values
boolean false
byte 0
char 'u0000'
String null
short 0
int 0
long 0L
float 0.0f
double 0.0d
8. Possible Values
boolean false, true
byte -128 to 127
char 'u0000' to 'uffff'
String ""
short -32,768 to 32,767
int -2,147,483,648 to 2,147,483,647
long -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
float 32-bit floating point
double 64-bit floating point
9. Variable Names
a-z, A-Z, 0-9, _, $
begin with a-z, A-Z, _, $
usually begin with a-z
$ rarely used
case sensitive: a ≠ A
camel case
10. Variable Names
valid preferred
$firstName firstName
_lastName lastName
Age age
zip_code zipCode
CITY city
rel2Per relationshipToPerson
addressline2 addressLine2
c count
11. Samples
boolean flag = true;
byte b = 0;
char character = 'a';
String firstName = "Marisa";
short age = 13;
int revolutionsPerHour = 65000;
long grainsOfSand = 14789409243948903;
float length = 21.5;
double pi = 3.1415926535897;