Primitive wrapper class in Java: Difference between revisions

Content deleted Content added
FR30799386 (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit
Missing hyphen
Tags: Mobile edit Mobile web edit
Line 1:
In object -oriented programming, 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 data types,<ref>S. J. Chapman, ''Introduction to Java'', Prentice Hall, 1999.</ref> so that these can be used to create instantiated objects with methods in another class or in other classes.<ref name=murach>J. Murach, ''Murach's Java Programming'', 4th Edition, Mike Murach and Associates, Inc., 2011.</ref><ref>J. R. Hubbard, ''Programming with Java'', Schaum's Outline Series/McGraw Hill, 1998.</ref> The primitive wrapper classes are found in the Java API.
 
Primitive wrapper classes are used to create an {{Javadoc:SE|java/lang|Object}} that needs to represent primitive types in {{Javadoc:SE|java/util|Collection}} classes (i.e., in the Java API), in the {{Javadoc:SE|package=java.util|java/util}} package and in the {{Javadoc:SE|package=java.lang.reflect|java/lang/reflect}} [[Reflection (computer science)|reflection]] package. Collection classes are Java API-defined classes that can store objects in a manner similar to how data structures like arrays store primitive data types like '''int''', '''double''', '''long''' or '''char''', etc.,<ref name=murach/> but arrays store primitive data types while collections actually store objects.