• Post Reply Bookmark Topic Watch Topic
  • New Topic

A Collection of javabeans Iterator  RSS feed

 
Higgledy Smith
Ranch Hand
Posts: 193
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I in my code I create a collection of Department javabeans. Department class contains an overridden toString() method.

In the Iterator code below, how do I guarantee the toString() used is the overridden Department toString and not the Java provided Object toString?

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is impossible for it to be anything else. If a class overrides a method, then no other class can call the original version on objects of that class; they can only call the new, overriding version.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!