Understand primitive data types in Java
- Details
- Written by Nam Ha Minh
- Last Updated on 18 August 2019 | Print Email
- byte: 8 bit (1 byte)
minimum value: -128 (-27)
maximum value: 127 (27-1)
- char: 16 bit (2 bytes)
minimum value: 0
maximum value: 65,535
- short: 16 bit (2 bytes)
minimum value: -32,768 (-215)
maximum value: 32,767 (215-1)
- int: 32 bit (4 bytes)
minimum value: -2,147,483,648 (-231)
maximum value: 2,147,483,647 (231-1)
- long: 64 bit (8 bytes)
minimum value: approx. -9,2 billions of billion (-263)
maximum value: approx. 9,2 billions of billion (-263-1)
Floating-point numbers:- float: 32 bit (4 bytes):
- double: 64 bit (8 bytes):
- Summary of all keywords in Java
- Some notes about arrays in Java
- Some notes about numeric literals in Java
Other Recommended Tutorials:
- 9 Rules about Constructors in Java
- 12 Rules and Examples About Inheritance in Java
- 12 Rules of Overriding in Java You Should Know
- 10 Java Core Best Practices Every Java Programmer Should Know
- Understand Interfaces in Java
- Understand how variables are passed in Java
About the Author:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.
Comments
I would like to report you a but, in primitives types section, in long is maximum value: approx. 9,2 billions of billion (-2^63-1), shouldn't be (2^63-1)?