JAVA Data Type
byte: The byte data type is an 8-bit signed two's complement
integer. -128 <= X <= 127. The byte data type can be useful
for saving memory in large arrays, where the memory
savings actually matters.
short: a 16-bit signed two's complement integer. It has a
minimum value of -32,768 <= 32,767.
As with byte, the same guidelines apply: you can use a short to save memory in
large arrays, in situations where the memory savings actually matters.
int: a 32-bit signed two's complement integer.
-2,147,483,648 <= X <=2,147,483,647 .
long: a 64-bit signed
two's complement integer. -9,223,372,036,854,775,808 <= X <= 9,223,372,036,854,775,807.
float: a single-precision 32-bit IEEE 754 floating point. Its
range of values is beyond the scope of this discussion, but is specified in the
Floating-Point
Types, Formats, and Values section of the Java Language Specification. As with the
recommendations for byte and short, use a float (instead of double) if you need
to save memory in large arrays of floating point numbers. This data type should
never be used for precise values, such as currency.
double: a double-precision 64-bit IEEE 754 floating point. Its
range of values is beyond the scope of this discussion, but is specified in the
Floating-Point
Types, Formats, and Values section of the Java Language Specification. For decimal
values, this data type is generally the default choice. As mentioned above,
this data type should never be used for precise values, such as currency.
boolean: 1 bit: true, false. Use this data type for simple
flags that track true/false conditions. This data type represents one bit of
information, but its "size" isn't something that's precisely defined.
char: The char data type is a single 16-bit Unicode
character. It has a minimum value of '\u0000' (or 0) and a maximum value of
'\uffff' (or 65,535 inclusive).
No comments:
Post a Comment