String[] str = new String[] { "a", "b", "c" };
System.out.println(str);
System.out.println(str.toString());
控制台输出结果如下:
[Ljava.lang.String;@1db9742
[Ljava.lang.String;@1db9742
原因如下:
http://blog.csdn.net/java2000_net/article/details/3041577
ArrayList继承AbstractList继承AbstractCollection
AbstractCollection实现Object类的toString方法。
public String toString() {
Iterator<E> it = iterator();
if (! it.hasNext())
return "[]"; StringBuilder sb = new StringBuilder();
sb.append('[');
for (;;) {
E e = it.next();
sb.append(e == this ? "(this Collection)" : e);
if (! it.hasNext())
return sb.append(']').toString();
sb.append(',').append(' ');
}
}