I have followings classes (it's just a simplified example):
public abstract class Material {
public abstract String name();
/* ... */
}
public class Wood extends Material {
@Override
public String name() {
return "<WOOD>";
}
/* ... */
}
public class Metal extends Material {
@Override
public String name() {
return "{Metal}";
}
/* ... */
}
public class Car<T extends Material> {
public void printName() {
System.out.println(T.name()); // Here is the problem!
}
/* ... */
}
public class Main {
public static void main(String[] args) {
Car<Wood> myCar1 = new Car<Wood>();
Car<Metal> myCar2 = new Car<Metal>();
myCar1.printName();
myCar1.printName();
}
}
The problem is indicated in the code.