Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Best way to operate unknown type objects?

889039Sep 19 2011 — edited Sep 21 2011
Hello,
I have 3 types of class:
A, B and C.
A is my created object containing few int and String fields. B extends A. And C extends B. Also A have int type field which defines its type.(A, B or C).
I can put them in to ArrayList<.A> or HashMap<.A> using int as key and later correctly retrieve using println method.
I would like to ask you what is the right way operating with those object if I don't know what type will be returned.
That means that type of variable use to store and operate retuned object.

I would be grateful for your help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 19 2011
Added on Sep 19 2011
27 comments
1,436 views