Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否可以将类设置为变量,这是我写的,但客观上我得到了编译错误。所以问题是,有没有办法将类存储在变量中?
package Enums; import Objects.*; public enum Pointer { PLAYER(Objects.player), BUTTON(GuiObjects.button); Class point; private Pointer(Class cla){ point = cla; } }
你忘记了.class后缀:
.class
PLAYER(Objects.player.class), BUTTON(GuiObjects.button.class)
此外:
Class<?>
Class<? extends BaseClass>
point
final