Reputation: 800
I was wondering if I could set a class as a variable, here is what i wrote, but objectively I get a compilation error.. So the question is , Is there a way to store a class in a variable ?
package Enums;
import Objects.*;
public enum Pointer {
PLAYER(Objects.player), BUTTON(GuiObjects.button);
Class point;
private Pointer(Class cla){
point = cla;
}
}
Upvotes: 0
Views: 101
Reputation: 121712
You forget the .class
suffix:
PLAYER(Objects.player.class), BUTTON(GuiObjects.button.class)
In addition:
Class<?>
; and if all your classes extend a base class, Class<? extends BaseClass>
;point
instance member can be final
.Upvotes: 6