3/07/2013

Autoboxing & Auto-unboxing in java


Autoboxing/Auto-unboxing:

(This Is Just an Basic Conversion For basic Knowledge)

It is an new features Added into jdk1.5.
the process in the primitive type is automated converted into its wrapper whenever an object of that type is needed.
There is no need of explicit casting.
It is very Important to Generics, which operates on Objects.
with autoboxing there in no need to construct an object to wrap a primitive type.


Integer abox=100 //autobox an int


To ubbox abox

int i=abox; // auto-unbox

Demo.java

class Demo{
public static void main(String args[])
{
Integer abox=100;

int a=abox;
System.out.println(a+"----"+abox);
}
}

1 comment:

  1. This pretty much applies to every job profile. Dissatisfaction , politics and people expecting you to know and do everything . I believe job positions that are extremely close to business side of things will be more rewarding . Decisions you take and mistakes you make must have the shortest path to revenue impacts , That is a place where you will be respected.
    Java training in Chennai | Java training institute in Chennai | Java course in Chennai

    ReplyDelete