Java Reference
In-Depth Information
All collection classes are generic classes. They declare formal type parameters. Specifying the Integer type in angle
brackets ( <Integer> ), while creating the List object, tells the compiler that the List will hold object of only Integer
type. This gives the compiler freedom to wrap and unwrap your primitive int values while you work with the List
object. Please refer to the chapter on generics in the topic Beginning Java Language Features (ISBN 978-1-4302-6658-7)
for more details.
Summary
For each primitive data type, Java provides a class to represent values of the primitive data type as objects. Java does
not support unsigned primitive numeric data types and unsigned numeric operations. Java 8 added limited support
for unsigned operations on primitive data types by adding some methods in the wrapper classes.
Java does not allow mixing of primitive type and reference type values in the same expression. It is inconvenient
to convert the primitive values to their wrapper objects and vice versa. Java 5 added support for automatically
converting the primitive values to wrapper objects and vice versa depending on the context. This feature is called
autoboxing/unboxing. For example, it allows assigning an integer 25 to a reference of the Integer object; the compiler
automatically boxes the integer 25 in a wrapper object using the expression Integer.valueOf(25) .
 
Search WWH ::




Custom Search