Im writing an exercise program that completed in the past using generic glasses but now I've encountered a very strange error that I haven't seen yet.
Test.java:26: error: type argument String is not within bounds of type-variable
T
Bag<String> b = new Bag<String>();
^
where T is a type-variable:
T extends Comparable<T> declared in class Bag
From what I make it's saying that class String does not implement the Comparable class. I've messed around with it for a while and I guess I'm making a small error somewhere but I can't see to see it. Any help would be appriciated. The code is:
class Bag<T extends Comparable<T>>
{
private T [] b = (T [])(new Comparable[100]); ;
int compareTo(T t)
{
return 0;
}
}
class Test
{
public static void main(String [] args)
{
Bag<String> bag = new Bag<>();
}
}