Results 1 to 1 of 1
Thread: Inheritance problem
- 04-02-2010, 03:55 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 1
- Rep Power
- 0
Inheritance problem
I have a generic class ObjectManager<T> which essentially offers limited functionality of an ArrayList:
Now, I would like to be able to have a class be Manager for several types of objects. The only solution I have come up with so far is instroducing a generic DoubleManager:Java Code:public class ObjectManager<T> { protected ArrayList<T> objects = new ArrayList<T>(); public void register(T o) { objects.add(o); } }
This way i would have to introduce a new Manager for each number of types that it should handle (TripleObjectHandler<T1,T2,T3>, ...), but at least it looks pretty elegant.Java Code:public abstract class DoubleObjectManager<T1, T2> extends ObjectManager<T2> { private ObjectManager<T1> manager = new ObjectManager<T1>(); public void register(T1 object) { manager.register(object); } }
The issue with this is that it leads to a nameclash. Both the register in the Manager and in the DoubleManager have the same erasure, which leads to a Name Clash.
Is there any way to solve this (without losing the generality of the method name register)? Or is there a better solution to the problem in the first place?
Similar Threads
-
Inheritance Problem
By g2beastie in forum New To JavaReplies: 4Last Post: 03-25-2010, 08:23 PM -
inheritance problem
By er1c550n20 in forum New To JavaReplies: 2Last Post: 03-10-2010, 06:01 PM -
Inheritance method problem
By Chasingxsuns in forum New To JavaReplies: 3Last Post: 11-10-2009, 08:30 PM -
Problem with Inheritance
By KronikAlkoholik in forum New To JavaReplies: 4Last Post: 08-25-2009, 12:13 AM -
Inheritance
By mew in forum New To JavaReplies: 1Last Post: 12-07-2007, 06:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks