Im trying to only allow specific classes to be used by the interact method. The code does not compile and does not recognize an underlying class to be part of the superclass.
Im using the following structure:
abstract class Interactable
abstract class Building extends Interactable
abstract class ContainerBuilding extends Building
class Cutter extends ContainerBuidling
Why does the code below not compile? Cutter.class is not recognized as a building class.
public static void main ( String[] args ) {
ActionTest.<Building>interact ( Cutter.class );
}
public static <T extends Interactable> void interact ( Class<T> interactableClass ) {
// do something
}
Does also not compile:
public static void main ( String[] args ) {
ActionTest.interact ( Cutter.class );
}
public static void interact ( Class<Interactable> interactableClass ) {
// do something
}