In Java, int and Integer are not same. One is a datatype where as the other is Wrapper class.
Similarly, we have wrapper classes for various data types as follows:
int --> Integer
long --> Long
short --> Short
byte --> Byte
char --> Character
double --> Double
float --> Float
boolean --> Boolean
With the help of wrapper classes, one can even know the range the datatype accepts. For example, if you want to print range for int, we can do as follows:
System.out.print("Range of int datatype is : " + Integer.MIN_VALUE + " to " + Integer.MAX_VALUE);
Post a Comment