Output of System.out.println(object)

后端 未结 4 834
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 09:35

I want to know what exactly the output is when I do the following.

class Data {
  int a = 5;
}

class Main {
  public static void main(String[] args) {
    d         


        
4条回答
  •  悲&欢浪女
    2020-11-29 10:15

    That code calls the default toString() implementation of the Object class, that is:

    public String toString() {
        return getClass().getName() + "@" + Integer.toHexString(hashCode());
    }
    

提交回复
热议问题