Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

declaring an array using an interface type

 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

One of the best uses of polymorphism in Java is to declare an array using an interface type, then add objects which can be from any class, as long as thay implement the interface type of the array


Is it possible for anyone to give the example codings for the above quoted thing.
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




I didn't try to compile it, but the idea should be clear.
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible for anyone to give the example codings for the above quoted thing.


 
Megs Maquito
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


not sure if this is correct though
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic