Data types in JAVA
- oanaunciuleanu
- 28 ian. 2018
- 1 min de citit

1. Byte

Example:
byte myByte = 10;
The default value for byte is 0.
The values are in the range: -128 .. -1,0,1, .. 127.
Size : 8 bits.
2. Short

Example:
short myShort = 1879;
The default value for short is 0.
The values are in the range: -32,768 .. -1,0,1, .. 32,767 .
Size : 16 bits.
3. Int

Example:
int myInt = -48592;
The default value for int is 0.
The values are in the range: -2147483648 ... 2147483647.
Size : 32 bits.
4. Long

Example:
long myLong = 100L;
The default value for long is 0L.
The values are in the range: -2^63 ... 2^63 -1.
Size : 64 bits.
5. Float

Example:
float myFloat = 7.36f;
The default value for float is 0.0f .
It is not precise.
Size : single-precision 32-bit IEEE 754 floating point
6. Double

Example:
double myDouble = 200.3d;
The default value for double is 0.0d .
Size : 64-bit IEEE 754 floating point
7. Char

Example:
chair myChar = 'a';
The default value for char is '\u0000' or 0, which is the minimum.
The maximum value is '\uffff' (or 65,535).
Char is a single 16-bit Unicode character.
8. Boolean

Example:
boolean myBoolean = true;
The default value for boolean is false.
The possible values are true and false.
Boolean data type represents one bit of information.
9. String

Example:
String myString = "Hello";
The default value for String, or any object is null.
String, meaning character strings is an object via the java.lang.String class.
String objects are immutable, which means that once created, their values cannot be changed.
Commenti