0

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 by Pyler

3
Contributors
4
Replies
21
Views
3 Years
Discussion Span
Last Post by Pyler
0

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

Edited by JamesCherrill

0

Hi,

private class KellyCoffee<Order> extends Queue implements OrderLineInterface

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

0

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 by Pyler

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.