String[] array = {\"a\",\"c\",\"b\"};
ArrayList list = new ArrayList();
list.add(\"a\");
list.add(\"b\");
list.add(\"
I just wonder why we can't call toString() directly on array to get the values.
Actually toString method is called on the array object. But, since array type does not override toString method from Object class, so default implementation of toString is invoked, that returns the representation of the form that you see.
The representation is of the form: -
[typeOfArray@hashCode
In your case it's something like: -
[Ljava.lang.String;@3e25a5
Whereas, in case of ArrayList instances, the overriden toString method in ArrayList class is invoked.