String[] array = {\"a\",\"c\",\"b\"};
ArrayList list = new ArrayList();
list.add(\"a\");
list.add(\"b\");
list.add(\"
Because when you print toString(), it will by default print className@HashCode.
So, when you print array then above will be printed.
But ArrayList is extened by AbstractCollection class and where the toString() method is overriden as below
public String toString() {
Iterator 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(' ');
}
}
which prints the readable format of the ArrayList object.