What is an Integer Data Type ?
In Java, the
which can hold any value between - 2,147,483,648 (-231) and 2,147,483,647 (231-1).
The primitive type
int num1 = 3;
Integer num2 = 4;
Integer total = num1 + num2;
int valueOfNum2 = total - num1;
The fixed values
The default value of a primitive
We will learn more about the wrapper class
- We can use an
int data type to store a String - We can use an
int data type to store a Boolean value of true or false. - A
int literal value can be enclosed in single or double quotes. - An
int literal value can be a negative or a positive number with the range of -231 and 231-1.
0 Comments