why the primitive data type have classes?

Answer Posted / manikandan [ gtec,vellore ]

there are different type of data types such as int,char
etc.for example suppose if we using arrays it can store a
similar data types but we need to store a char and int in a
same array what can we do for this situation. the wrapper
class helps in this situation by storing a objects in to a
arrays.

example

ArrayList v=new ArrayList();
v.add(new Integer(1));
v.add(new Character('a'));//

the int and char are different type but we stores it by an
object.

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many ways can you break a singleton class in java?

703


What are parameters in a method?

780


What is r in java?

778


How do you use compareto in java?

736


Can we restart a thread already started in java?

803


What do you mean by multithreaded program?

753


Difference between string, string builder, and string buffer?

732


Does every java program need a main?

742


Write a program to reverse a number in java?

781


What is a priority queue java?

707


Is it correct to say that due to garbage collection feature in java, a java program never goes out of memory?

797


Can an object subclass another object?

755


What are the differences between heap and stack memory?

753


Can we split string with in java?

735


What do bitwise operators do?

716