Wrapper Classes

Wrapper class is a part of java.lang, which wraps the primitive data values into objects. Wrapper classes are needed for an object representation for primitive type variables to use Java built-in methods. Java has wrapper class for each of the eight primitive data types. Data type starts with lowercase letters, whereas its wrapper class starts with an uppercase letter.

Wrapper constructors create class objects from primitive types. Each wrapper provides a method to return the primitive value. In Java, strings can be used in three different ways: Character class, String class and StringBuffer class. Character class holds single character or group of characters. In string class, objects hold unchanging string (immutable). In StringBuffer class, objects hold mutable strings that can be changed or modified. In Java, strings get created in two different ways: by declaring the object of the String class and by creating string objects using a new operator with a constructor. StringBuffer class is a part of java.lang package and an alternative to the String class. StringBuffer objects are always created with new operator. The methods used to obtain information about an object are known as accessor methods. String class provides many accessor methods that can be used to perform different operations on strings. Package is a way to group related class and interface into one unit. Package in Java program can be included by using import command.

To Access the full content, Please Purchase