Hi,
I am placing some code here...
public class GenericBox1
{
public <U> void inspect(U u)
{
System.out.println(u.getClass().getName());
}
public static void main(String[] args)
{
GenericBox1 ob=new GenericBox1();
System.out.println("Passing Integer object");
ob.inspect(new Integer(10));
System.out.println("Passing Double object");
ob.inspect(10.34); //..............see this line
System.out.println("Passing String object");
ob.inspect("affaffaf");
Integer intobject=new Integer(24);
System.out.println("Passing Integer object");
ob.inspect(intobject);
}
}
In my code i am passing a primitive type 10.34 instead of a object.
But i read that we can't pass primitive types as a formal type parameter in generics use.
But here i did it.
but it didn't show any error.it works well.
what is the reason for this ?
is this the example for auto boxing and unboxing ?