I was reading jls 8
and I got stuck on Example 8.1.2-1, Mutually Recursive Type Variable Bounds
I searched stackoverflow, and found a question what is a mutually recursive type? but this was not in terms of Java.
Example 8.1.2-1. Mutually Recursive Type Variable Bounds
interface ConvertibleTo<T> {
T convert();
}
class ReprChange<T extends ConvertibleTo<S>,
S extends ConvertibleTo<T>> {
T t;
void set(S s) { t = s.convert(); }
S get() { return t.convert(); }
}
Question:
What does Recursive Type and Mutually Recursive Type means in Java?
Here what does
T extends ConvertibleTo<S>, S extends ConvertibleTo<T>
means?If I just use
T extends ConvertibleTo<S>
as type parameter for class ReprChange I am getting compile time error?