Professional Documents
Culture Documents
Primitive Wrapper
Type
Class
Primitive
Type
Wrapper
Class
boolean
Boolean
float
Float
byte
char
double
Byte
Character
Double
int
long
short
Integer
Long
Short
Integer i2 = Integer.valueOf(42);
Boolean b2 = Boolean .valueOf(true);
Long n1 = Long.valueOf(42000000L);
System.out.println(bool);
System.out.println(c);
System.out.println(b);
System.out.println(s);
System.out.println(i);
System.out.println(l);
System.out.println(f);
System.out.println(d);
}
Integer i1 = Integer.valueOf(42;
Boolean b1 = Boolean.valueOf(false);
System.out.println(i1.intValue());
System.out.println(b1.boolValue());
=>
42
false
Integer.parseInt(42)
=> 42
Boolean.parseBoolean(true) => true
Double.parseDouble(2.71)
=> 2.71
//
System.out.println(Integer.parseInt(args[i]));
} catch (Exception e) {
try {
System.out.println(Float.parseFloat(args[i]));
}
finally {
}
}
}
=>
arg
arg
arg
arg
arg
arg
#
#
#
#
#
#
0
1
2
3
4
5
=
=
=
=
=
=
0
42
999
0.0
1.42
9.0008
=>
For Boolean & Character Wrappers (Objects wrappers):
Boolean:true
Character:a
For Number wrappers:
Byte:100
Short:32000
Integer:2000000
Long:500000000000000000
Float:1.42
Double:1.42
=>
Byte:127
Short:32767
Integer:2147483647
Long:9223372036854775807
Float:3.4028235E38
Double:1.7976931348623157E308
static
static
static
static
static
static
static
static
static
static
int
int
int
int
int
int
int
String
String
String
String
hashCode()
numberOfLeadingZeros(int i)
numberOfTrailingZeros(int i)
reverse(int i)
reverseBytes(int i)
rotateLeft(int i, int distance)
rotateRight(int i, int distance)
toBinaryString(int i)
toHexString(int i)
toOctalString(int i)
toString(int i, int radix)
import java.util.Map;
import java.util.TreeMap;
public class Freq {
private static final Integer ONE = new Integer(1);
public static void main(String args[]) {
// Maps word (String) to frequency (Integer)
Map m = new TreeMap();
for (int i=0; i<args.length; i++) {
Integer freq = (Integer) m.get(args[i]);
m.put(args[i], (freq==null ? ONE :
new Integer(freq.intValue() + 1)));
}
System.out.println(m);