Primitive wrapper class in Java: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 1:
In object oriented programming and in the [[Java (programming language)|Java]] language in particular, a '''wrapper class''' is a class that [[Encapsulation (computer_programming) |encapsulates]] types, so that those types can be used to create object instances and methods in another class that need those types. So a '''primitive wrapper class''' is a wrapper class that encapsulates, hides or ''wraps"'' data types from the eight primitive types, so that these can be used to create instantiated objects with methods in another class or in other classes. The primitive wrapper classes are found in the Java API.
 
Primitive wrapper classes are used to represent the primitive types when an {{Javadoc:SE|java/lang|Object}} is required. The wrapper classes are used extensively with {{Javadoc:SE|java/util|Collection}} classes in the {{Javadoc:SE|package=java.util|java/util}} package and with the classes in the {{Javadoc:SE|package=java.lang.reflect|java/lang/reflect}} [[Reflection (computer science)|reflection]] package. Collection classes are classes that contain objects in a manner similar to how data structures like arrays can store integer, double or character values.