Wrapper Classes in Java

For every primitive data, there are corresponding wrapper classes. There are total eight primitive data type and eight corresponding wrapper classes which are listed below:

  1. byte : Byte
  2. short: Short
  3. int : Integer
  4. long : Long
  5. float: Float
  6. double : Double
  7. char : Character
  8. boolean: Boolean

All these Wrapper classes are available in java.lang package developed by Sun Developers.


Important Points to ponder:

  1. Every wrapper class is a final class.
    For Example: public final class Short{ …}
  2. Every Wrapper class is a type of comparable. Since every Wrapper class is implementing Comparable class we can do sorting of the members of these classes.
  3. Every Wrapper class is a type of Serializable. Every wrapper oblect is eligible for Serialization.
  4. In every Wrapper class , these three methods : toString(), hashcode() and equals () method are overridden..
Facebook Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.