Tuesday, May 15, 2012

Know Java? Know primitives!

Java logo.svg

Well, this may not be news for the most of you java gurus out there, but many a times, the primitives DO need a revisit.

Primitives refer to the base types offered ‘out-of-the-box’ by the Java programming gamut.

The base need of primitives arose due to the advertising and popularity of Java as a compile once – run anywhere paradigm.

Anyways, the below table should be a harmless refresher for that primitive coder in you ;-)

Data Type 
Size (in bits) Default Value (for fields)
byte 8 0
short 16 0
int 32 0
long 64 0L
float 32 0.0f
double 64 (yes, same as long :-) ) 0.0d
char 16 '\u0000'
boolean 1 FALSE

Hope this gives some quick help to someone out there!

No comments: