I am writing some classes using Generics but I can\'t find a solution for the class SolutionsSubset and so I a getting the error \"type parameter S is not within its bound\"
In order to be used as the type argument in MathSubset, SolutionsSubsets S must extend Comparable. As a compilable example:
import java.util.TreeSet;
interface Subset>
extends Comparable> { }
class MathSubset>
extends TreeSet
implements Subset
{
public int compareTo(Subset other) { throw new Error(); }
}
interface Solution> { }
interface Solutions> extends Iterable { }
class SolutionsSubset & Comparable>
extends MathSubset
implements Solutions
{ }
A few comments: This is very abstract example, and so not easy to think about. Laying out the code so you don't need to scroll is good. There's an awful lot of inheritance going on here, perhaps compose rather than, say, extending TreeSet. It's difficult to distinguish between the identifiers Solutions and Solution.