Psoop-Wrapper Classes-24-25
Psoop-Wrapper Classes-24-25
JAVA
-Compiled by Nikahat Mulla
Agenda
• Wrapper Classes
2
Wrapper Classes
• Java treats objects differently from variables of Primitive types
6
Wrapper Classes (Contd…)
• The java.lang package contains a wrapper class that
corresponds to each primitive type:
Primitive Wrapper
Constructor Arguments
Type Class
int i = intobj.intValue();
Integer
Constructors
Integer(int value)
Integer(String s)
Constants (static)
class AutoBox {
public static void main(String args[]) {
Integer iOb = 100; // autobox an int
int i = iOb; // auto-unbox
System.out.println(i + " " + iOb);
}
}
Examples:
Character.toLowerCase(ch)
Character.isLetter(ch)
Example:
String s = "65000";
int i = Integer.parseInt(s);
Thank You