This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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
Posts: 53750
127
  • 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
Posts: 53750
127
  • 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
Posts: 53750
127
  • 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
Boost this thread!