BOOLEAN – True/False[0 or 1]
The boolean
data type has two possible values, either true
or false
. The default value is false. The implementation of Boolean is as follow
class Main {
public static void main(String[] args) {
boolean flag = true;
System.out.println(flag); // prints true
}
}
Figure 1.4 – Boolean Variable Declaration And initialization
BYTE
The byte
data type can have values from -128 to 127 (8-bit signed two’s complement integer). The usage of this datatype strictly depends on the range that is going to be in-between the rage that the datatype supports. The implementation will be as follow
class Main {
public static void main(String[] args) {
byte range;
range = 124;
System.out.println(range); // prints 124
}
}
Figure 1.5 – Byte Variable Declaration And initialization
Pages: 1 2