posted 12 years ago
Hi Pintu,
Welcome to coderanch!
This behaviour is because of the ways in which toString() method is implemented in class Object and class ArrayList (ArrayList overrides Object's toString() method).
toString() of Object prints class name, followed by '@' symbol, followed by hashCode of that object.
toString() of ArrayList prints all the members of the list within square brackets, and members are separated by comma (','). How each member of that list is printed will further be decided on that class' toString() method. e.g. while printing ArrayList of Employee, first toString() of ArrayList will be called, followed by toString() method for all members (i.e. toString() method of Employee class - if it is overridden. Otherwise, toString() of Object will be called).
I hope this helps.
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)