?? testtostring.java
字號(hào):
/***
*
* 掌握toString的使用
* @author Administrator
*
*/
public class TestToString {
public static void main(String[] args) {
Dog d = new Dog();
System.out.println("d:=" + d);
Dog1 t =new Dog1();
//下面寫法 輸出結(jié)果相同
System.out.println(t.toString());
System.out.println(t);
}
}
class Dog {
//調(diào)用了api中的 toString方法,使得可以輸出返回值
public String toString() {
return "I'm a cool dog!";
}
}
class Dog1 {
//輸出的結(jié)果是 類名+ @ + 哈希編碼
//getClass().getName() + '@' + Integer.toHexString(hashCode())
//Dog1@11b86e7
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -