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

Explain why wait(), notify() and notifyall() methods are in object class rather than in the reading class?

567


What does this mean java?

563


What is the major difference between linkedlist and arraylist?

514


What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?

1944


What is meant by singleton class?

604






Is it safe to install java on my computer?

546


give an example for encapsulation?

588


Give reasons supporting that string is immutable.

507


can java object be locked down for exclusive use by a given thread? : Java thread

537


What is a boolean flag in java?

571


What is numeric data type?

535


Tell me the latest versions in java related areas?

589


What are the differences between abstract class and interface?

515


When throws keyword is used?

586


Why main() method is public, static and void in java ?

603