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

Why do we need hashmap in java?

646


Explain about join() method?

639


Can a class be final?

582


Can we have return statement in finally clause? What will happen?

609


What is difference between core java and java ee?

556






What is stringbuffer in java?

653


Why inputstreamreader is used in java?

644


Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?

762


What is a instance variable in java?

655


What is numeric data type?

622


Can we return null in java?

722


What is json parser in java?

706


When is the finalize() called? What is the purpose of finalization?

688


Can we sort hashset in java?

740


What should I import for arraylist in java?

604