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

Why does it print "ALL"

 
Esther Kak
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody explain this.....Why does it print "ALL"

 
Andy Morris
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because toString() is automatically invoked by your System.out.println() invocation and since you overwrote that method it prints out 'ALL'.
 
Henry Wong
author
Marshal
Pie
Posts: 21507
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The PrintStream's println() method that takes an Object, calls toString() to get a string object to print.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic