Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
jaspreet atwal
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Campbell Ritchie
Sheriff
Pie
Posts: 50235
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50235
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually go into the AbstractCollection class and look for the toString() method.
 
jaspreet atwal
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That answers my question, Thank you!!
 
Campbell Ritchie
Sheriff
Pie
Posts: 50235
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jaspreet atwal:
That answers my question, Thank you!!
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic