aspose file tools*
The moose likes Beginning Java and the fly likes how System.out.println(ArrayList al) works? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how System.out.println(ArrayList al) works?" Watch "how System.out.println(ArrayList al) works?" New topic
Author

how System.out.println(ArrayList al) works?

jaspreet atwal
Ranch Hand

Joined: Sep 05, 2007
Posts: 52
I have realized that if I use the above method on an existing ArrayList, System.out.println will print each element there in my ArrayList. e.g I have an ArrayList as below:



and I pass it to System.out.println(), it will print each element in the ArrayList. How does it make it possible.



Still Learing..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38357
    
  23
Find your Java installation folder and explore it until you find a file called "src.zip". Unzip it into a folder called src, then explore to find the java folder then the util folder then the ArrayList file then read the toString() method.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38357
    
  23
Actually go into the AbstractCollection class and look for the toString() method.
jaspreet atwal
Ranch Hand

Joined: Sep 05, 2007
Posts: 52
That answers my question, Thank you!!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38357
    
  23
Originally posted by jaspreet atwal:
That answers my question, Thank you!!
You're welcome
 
wood burning stoves
 
subject: how System.out.println(ArrayList al) works?