04-24-2011, 05:28 PM
what is boxing or unboxing and what is the uses of it in java language, ? and also give the syntax of it
|
what is boxing or unboxing and what is the uses of it in java language, ?
|
|
04-24-2011, 05:28 PM
what is boxing or unboxing and what is the uses of it in java language, ? and also give the syntax of it
04-24-2011, 05:29 PM
Boxing & unboxing is the process of converting a primitive value into an object oriented wrapper class (boxing), or converting a value from an object oriented wrapper class back to the primitive value (unboxing).
Java 5 supports automatic conversion of primitive types (int, float, double etc.) to their object equivalents (Integer, Float, Double,…) in assignments, method and constructor invocations. This conversion is know as autoboxing. Java 5 also supports automatic unboxing, where wrapper types are automatically converted into their primitive equivalents if needed for assignments or method or constructor invocations.For example: int inative =0; inative = new Integer(5); // auto-unboxing Integer intObject =5 ; // autoboxing |
|
« Next Oldest | Next Newest »
|