今天复习集合Collection时
Collection c=new ArrayList(); System.out.println(c);//[孙悟空, aaa]
很好奇这个toString()方法
-
Object中:
public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()); }
-
Collection的实现类应该重写了toString()方法,然而并没有找到
-
查看继承结构:
-
在AbstractCollection中发现重写了该方法: