This discussion is archived
1 Reply Latest reply: Jan 25, 2013 7:15 PM by EJP RSS

Realized type from Inherited generic parent

987253 Newbie
Currently Being Moderated
Lets say I have the following classes
class Fruit
class Orange extends Fruit

class FruitVendor<T extends Fruit>
class OrangeVendor<T extends Orange> extends FruitVendor
What I want to do is create a class that can take a specific action on that type, that inherits from the parent. But I dont want to have to specify the generic type when I declare an instance.
// What I must do
OrangeVendor<Orange> vendor = new OrangeVendor<Orange>();

// What I want
OrangeVendor vendor = new OrangeVendor();
How can I accomplish this?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points