can anyone explain me the concept of autoboxing?

Answer Posted / srinu

auto boxing:-
The process of conversion of primitive data type into wraper
class object into AUTOMATICALLY is called Auto boxing.
By using generic types of java 1.5,we an acheive it
easily.By declaring, the collection classes as shown below
we can do it.
EX:

HashSet<Integer> hs=new HashSet<Integer>();
hs.add(1);
hs.add(2);
Iterator it=hs.iterator();
while(it.hasNext())
{

System.out.println(it.next());
}
(Note: original it.next() returns object but here
System.out.println print primitive datatypes.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where are variables stored?

556


What is the platform?

540


Can we have any code between try and catch blocks?

565


what is daemon thread and which method is used to create the daemon thread? : Java thread

539


What are the main uses of this keyword?

603






What is a method signature java?

583


What is the synchronized method modifier?

596


Write a program to search a number in the given list of numbers.

636


What is a values collection view ?

685


How can you write a loop indefinitely in java programming?

556


Explain what pure virtual function is?

603


Is char * a string?

544


Difference between object instantiation and construction ?

590


Which list does not allow duplicates in java?

517


What are access specifiers in java ?

593