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?

Edited 2 Years Ago by Pyler

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

Edited 2 Years Ago by JamesCherrill

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

Edited 2 Years Ago by Pyler

This question has already been answered. Start a new discussion instead.