Data Type | Primitive | Class |
---|---|---|
int | X | |
String | X | |
long | X | |
double | X | |
Random | X | |
boolean | X | |
Scanner | X |
The correct way to do this is to recognize the primitive data types. Everything else must be a class. Class names usually begin with a capital letter, but this is not required by syntax.
public class EgLong { public static void main ( String[] args ) { long value; value = 18234; System.out.println( value ); } }
The example program uses primitive data type long
for
the variable value
.
The statement
value = 18234;
puts a particular bit pattern in that 64 bit section of memory.
With primitive data types, a variable is a section of memory reserved for a value that uses that data type.
For example by saying long value
, 64 bits of memory are reserved for
an integer. By saying int sum
, 32 bits of memory are reserved an integer.
Object reference variables do not work this way, however. The next several pages discuss this.