Wrapper class.pdf - Wrapper class in Java Javatpoint ADVERTISEMENT Wrapper classes in Java The wrapper class in Java provides the mechanism to convert

Wrapper class.pdf - Wrapper class in Java Javatpoint...

This preview shows page 1 - 3 out of 7 pages.

12/2/2019 Wrapper class in Java - Javatpoint 1/7 ADVERTISEMENT Wrapper classes in Java The wrapper class in Java provides the mechanism to convert primitive into object and object into primitive . Since J2SE 5.0, autoboxing and unboxing feature convert primitives into objects and objects into primitives automatically. The automatic conversion of primitive into an object is known as autoboxing and vice-versa unboxing. Use of Wrapper classes in Java Java is an object-oriented programming language, so we need to deal with objects many times like in Collections, Serialization, Synchronization, etc. Let us see the different scenarios, where we need to use the wrapper classes. Change the value in Method: Java supports only call by value. So, if we pass a primitive value, it will not change the original value. But, if we convert the primitive value in an object, it will change the original value. Serialization: We need to convert the objects into streams to perform the serialization. If we have a primitive value, we can convert it in objects through the wrapper classes. Synchronization: Java synchronization works with objects in Multithreading. java.util package: The java.util package provides the utility classes to deal with objects. Collection Framework: Java collection framework works with objects only. All classes of the collection framework (ArrayList, LinkedList, Vector, HashSet, LinkedHashSet, TreeSet, PriorityQueue, ArrayDeque, etc.) deal with objects only. The eight classes of the java.lang package are known as wrapper classes in Java. The list of eight wrapper classes are given below: Primitive Type Wrapper class boolean Boolean char Character byte Byte short Short int Integer long Long float Float double Double
Image of page 1
12/2/2019 Wrapper class in Java - Javatpoint 2/7 Autoboxing The automatic conversion of primitive data type into its corresponding wrapper class is known
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 7 pages?

  • Fall '19
  • sumit

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors