Java Integer
Last Updated on Tuesday, 28 June 2011 15:22
|

Java Integer
The Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.In addition, this class provides several methods for converting an int to a String and a String to an int, as well as other constants and methods useful when dealing with an int.
Memory size of a java.lang.Integer
A java.lang.Integer costs 16 bytes. An int value can fit into just 4 bytes. Using an Integer costs 300 percent memory overhead compared to a primitive type.
Passing integer by reference
By default Java parameters are always passed by values. An easy way to pass by reference is to use a single element array.
Let's define a Junit test case to illustrate an example :





