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

Info iconThis 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
Background 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

This note was uploaded on 06/11/2009 for the course CS 205214 taught by Professor Balasooriya/kouvetakis during the Spring '09 term at ASU.

Ask a homework question - tutors are online