wrapperClass - int corresponding to the value stored in the...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Wrapper Classes A wrapper class represents a particular primitive data type. (primitive data types – int, double, char, boolean, and so on) They are defined in the java.lang package. Instead of declaring an integer as primitive data as: int number1 = 45; We can declare it as an object of the Integer (wrapper) class. Integer number1 = new Integer(45); For instance, the method doubleValue() returns the value of this integer as double. The class Integer also has static methods such as parseInt(String str) that returns the
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int corresponding to the value stored in the parameter string. Since it is static, it can be called with the class name (without instantiating an obejct) as: int num = Integer.parseInt(“11”); Then “num” will contain the integer 11. Also see other wrapper classes such as Double. (e.g., double num2 = Double.parseDouble(“3.21”); )...
View Full Document

{[ snackBarMessage ]}

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