• Post Reply Bookmark Topic Watch Topic
  • New Topic

T cannot be resolved to a type  RSS feed

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone help please I have an assignment
Write an CircularArrayRing<E> class which implements the Ring<T> interface and extends AbstractCollection<E>.

the code for ring

So, stupid question but still when I am doing:

It gives me an error about T saying T cannot be resolved to a type and the interface collection cannot be implemented more than once with different arguments Collection<E> and Collection<T>. but the methods inside the class must include this T.

How can I solve this problem?
 
Ranch Hand
Posts: 479
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is slightly out of my field, but it seems to me that your declaration of the class must name what the interface takes as its parameter. When you use this class with generics, there is no chance at that time to name what T will represent. So it can't be a generic in that way at that point, unless there is (yet) more generics syntax with which I am not familiar...

Perhaps some kind admin would move this to the general forum? I don't think generics are a beginning concept at all.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anissa Pary wrote:Can anyone help please I have an assignment
Write an CircularArrayRing<E> class which implements the Ring<T> interface and extends AbstractCollection<E>.


Looks like a typo. Should be Ring<E>.
 
Anissa Pary
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK Thank you! I get it that there should be
So is the same change should be for the method?

and Question number 2 how this method should know which <E> to take? CircularArrayRing<E> or AbstractCollection<E> or Ring<E> or there is no matter?
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The <E> is a "type parameter"; it means the same type throughout the class which it parametrizes.
 
Anissa Pary
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:The <E> is a "type parameter"; it means the same type throughout the class which it parametrizes.

thank you!:D
 
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:
Anissa Pary wrote:Can anyone help please I have an assignment
Write an CircularArrayRing<E> class which implements the Ring<T> interface and extends AbstractCollection<E>.


Looks like a typo. Should be Ring<E>.

Actually I don't think so. The interface probably uses generic type <T>. The solution is to use E as the value for T. The solution is the same though - Ring<E>.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:
Jeff Verdegan wrote:
Anissa Pary wrote:Can anyone help please I have an assignment
Write an CircularArrayRing<E> class which implements the Ring<T> interface and extends AbstractCollection<E>.


Looks like a typo. Should be Ring<E>.

Actually I don't think so. The interface probably uses generic type <T>.


Not the Ring interface code she provided in the OP, which I assume came from the instructor. Still, it could have been that he meant the T in that sort of "placeholder" sense in the problem statement. Kind of makes it confusing though.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!