Java Data Types
Java defines eight types of data: byte, short, int, long, char, float, double, and boolean.
These data types can be put in four groups:
- Integers This group includes byte, short, int, and long, which are for whole-valued signed numbers.
- Floating-point numbers This group includes float and double, which represent numbers with fractional precision.
- Characters This group includes char, which represents symbols in a character set, like letters and numbers.
- Boolean This group includes boolean, which is a special type for representing true/false values
Integer
Floating-Point Types
Characters
In Java, the data type used to store characters is char. However, C/C++ programmers beware:
char in Java is not the same as char in C or C++. In C/C++, char is 8 bits wide. This is not the
case in Java, it requires 16 bits. Thus, in Java char is a 16-bit type. The range of a char is 0 to 65,536. There are no negative chars.
char in Java is not the same as char in C or C++. In C/C++, char is 8 bits wide. This is not the
case in Java, it requires 16 bits. Thus, in Java char is a 16-bit type. The range of a char is 0 to 65,536. There are no negative chars.
No comments:
Post a Comment