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

What is the use of flag?

582


What is hashmap and map?

554


What is a copy constructor in java?

579


What will happen if non-synchronized method calls a static synchronized method and what kind of lock it acquires?

514


Explain the features of interfaces in java?

555






What are the different types of methodologies?

527


Why super is first line in java?

559


what are abstract functions?

558


How do you escape json?

541


What are autoboxing and unboxing? When does it occur?

534


What is the finalize method do?

597


Can we compare two strings in java?

554


How do you empty a list in java?

537


v-model life cycle

1618


How can you avoid serialization in child class if the base class is implementing the serializable interface?

638