Suppose I have the following generic classes;

Queue<T>
KellysCoffee
CheckOut

and the following generic interfaces

QueueInterface
OrderLineInterface

Suppose I want KellysCoffee to extend Queue class and implement OrderLineInterface
This is how I've done it

private class KellyCoffee<Order extends Queue<Order>> implements OrderLineInterface{}

Now when I try to implement CheckOut

public class CheckOut<Order> extends KellysCoffee<Order>{}

I get a bound mismatch error saying

The type Order is not a vlaid substitute for the bounded parameter <Order extends Queue<Order>> of the type KellysOrder<Order>

when I try to extend KellyCoffee

Is there a way to fix this?

Recommended Answers

All 4 Replies

<Order extends Queue<Order>> looks wrong (?)
How can Order be a subclass of Queue<Order> ?

Hi,

private class KellyCoffee<Order> extends Queue implements OrderLineInterface

Otherwise, the declaration seems wrong : a class can't extend herself.

That yeilds the following error:

The interface QueueInterface cannot be implemented more than once with different arguments: QueueInterface<Order> and QueueInterface<Order>

Emphasized Text Here

Fixed it. More on the solution later.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.