The eight primitive data types byte, short, int, long, float, double, char and boolean are not objects, Wrapper classes are used for converting primitive data types into objects, like int to Integer etc.
For example , The Integer is a wrapper class of int primitive type.
The wrapper objects hold much more memory compared to primitive types. So use primitive types when you need efficiency and use wrapper class when you need objects instead of primitive types.
public class test{
public static void main(String args[]){
//Converting int primitive into Integer object
int a=100;
Integer obj=Integer.valueOf(a);
System.out.println(a+ " "+ obj);
}
}
Output:
100 100
TCCI can help student to grasp such an important topics very well.
We have located in Bopal and Satellite in Ahmedabad.
To inquire Call us @ 98256 18292.
Visit us @tccicomputercoaching.com
No comments:
Post a Comment