This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Why does it print Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Why does it print "ALL"" Watch "Why does it print "ALL"" New topic

Why does it print "ALL"

Esther Kak
Ranch Hand

Joined: Oct 11, 2006
Posts: 51
Can somebody explain this.....Why does it print "ALL"

Andy Morris
Ranch Hand

Joined: May 30, 2004
Posts: 78
Because toString() is automatically invoked by your System.out.println() invocation and since you overwrote that method it prints out 'ALL'.
Henry Wong

Joined: Sep 28, 2004
Posts: 18113

The PrintStream's println() method that takes an Object, calls toString() to get a string object to print.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: Why does it print "ALL"
Similar Threads
Enclosing Class with static methods
Multidimensional array
Elementary Stuff
Read file from directory, update contents of the each file
Confused in equals working and its overriding