| Data Type | Primitive | Class |
|---|---|---|
| int | X | |
| String | X | |
| long | X | |
| double | X | |
| Applet | X | |
| boolean | X | |
| Graphics | X |
The correct way to do this is to recognize the primitive data types. Everything else must be a class.
Here is a tiny program that uses a primitive data type:
class egLong
{
public static void main ( String[] args )
{
long value;
value = 18234;
System.out.println( value );
}
}
|
In this program,
the variable value is the name for a 64 bit section of memory
that is used to hold long integers.
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 of a particular style.
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 will discuss this.