==object 类
object类是所有类的父类。
1. public boolean equals(object obj) : comparing if two object content are same or not
2. public String toString() : what to be printed int println
3. public int hashCode() : get the hash code
所有类都可以override这些方法。
==包装类
8种基本类型不是类,但是java要求一切都是类。所有8种基本类型有对应的包装和解包装方法
1. based on class Object
Boolean
Character
2. based on class Number
Method
Byte byteValue()
Float floatValue()
Double doubleValue()
Integer integerValue()
Short shortValue()
Long longValue()
3. example:
int i = 30;
Integer i = Integer(i);
int j = i.intValue();
After JDK1.5
Integer i =30;
int j = i;
4. application
Integer: public static int parseInt(String s);
Float: public static float parseFloat(String s);
没有评论:
发表评论