File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Simple oop question - duplicate call to different instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple oop question - duplicate call to different instance" Watch "Simple oop question - duplicate call to different instance" New topic
Author

Simple oop question - duplicate call to different instance

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Sorry if the title unclear, I will explain:
Say I got abstract class ABS with some methods implemented in it:


And two derived classes FOO,BAR


Now I would like to create list of ABS



How do i avoid the duplicate calles to setId, setName,setSerialNumber in the If clause?
Thank you
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Thank you,how do you deal with instantiating FOO,BAR
And avoid the ugly casting from ABS to FOO,BAR?

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19678
    
  18



SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: Simple oop question - duplicate call to different instance