can anyone explain me the concept of autoboxing?
Answers were Sorted based on User's Feedback
Answer / durga ganesh reddy
autoboxing is that the conversion of primitive data types
into wrapper class objects automatically.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.
HashSet<Integer> hs=new HashSet<Integer>();
hs.add(1);
hs.add(2);
Iterator it=hs.iterator(0;
while(it.hasNext())
System.out.println(it.next());
| Is This Answer Correct ? | 11 Yes | 0 No |
Answer / jitu
In case of autoboxing directly the value of the constructor
assign to a variable.i.e object of wrapper class directly
assign to a variable.but it is only possible in case of 1.5
version.
Ex:public class X
{public static void main(String a[])
{Integer i1=new Integer("20");
Integer i2=new Integer("20");
int m1=i1;
int m2=i2;
S.o.p(m1+m2);o/p-20
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / 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 |
In which language java is written?
What is polymorphism java example?
What is an enumeration?
I have one POJO class(Java bean class), it has two variables for that it has setters and getters. Now i have created two objects for that class and i have set the data for those variables through this two objects. Now question is i want check whether those two objects have same data or not, for this write a program? Thanks, Bose.
Print Vertical traversal of a Binary Tree.
When should you use arraylist and when should you use linkedlist?
java program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
What about static nested classes in java?
what are the uses of Class class and what it returns? explain it with the example code.
explain multi-threading in java?
What is a predicate method?
What super () does in java?