1. 程式人生 > >Directly output the object name

Directly output the object name

print output oid 默認 pri class public basic col

package basic.java;

public class Case {
    public static void main(String[] args) {
        Student s = new Student();
        System.out.println(s);
    }
}

basic.java.Student@19bb25a

輸出的結果是包名.

package basic.java;

public class Case {
    public static void main(String[] args) {
        Student s 
= new Student(); System.out.println(s); System.out.println(s.name); System.out.println(s.age); } } basic.java.Student@1e58cb8 null 0

String是一個引用類型的類,所以默認輸出的是null。

Directly output the object name