KIO
Kreative Ideen online

Variables come in two flawors:

  • Primitives
  • Reference

Primitives

Primitives hold fundamental values (think: simple bit patterns)

Bool and char
boolean = (JVM-specific)| true / false
boolean fun = true;

char = 16bits | 0 to 65535
char c = 'g';

Numeric – integer
byte = 8 bits | -128 to 127
byte b = 89;

short = 16 bits | -32768 to 32767
short s = 10;

int = 32 bits | -2147483648 to -2147483648
int i = 300;

long = 64 bits | huge to huge
long L = 3498989;

Floating points
float = 32 bits | varies
float f = 32.4f;
(Note the ‘f’. Gotta have that with a float, because Java thinks anything with a floating point is a double, unless you use ‘f’)

double = 64 bits | varies
double d = 3222.77;

Be Careful! Bears Shouln’t Ingest Large Furry Dogs

boolean char byte short int long float double

more technical explanation click here

References

References are names. Objects are stuff. You can have different names for stuff, even for stuff that doesn’t actually exist.
You can declare names, without actually giving them any “real” meaning, like this:
Employee emp = new Employee();
emp = a reference

Leave a Reply

Your email address will not be published. Required fields are marked *