Thursday, March 29, 2012

How many bits are used to store a long variable, in Java?

How many bits are used to store a long variable, in Java?
64-bits.

Here are the primitive data types in Java and their sizes:
  • byte       8-bits
  • short    16-bits
  • int        32-bits
  • long     64-bits
  • float     32-bits
  • double 64-bits
  • char     16-bits
  • boolean  unknown (I know it seems weird why the answer is not 1-bit. If you know the reason, please add a comment!)
 
 For more details, check the reference. 

No comments:

Post a Comment

Please, before starting to comment, evaluate if what you want to write is useful, respectful and positive. A kid may read this also.

Give a good example!