你好!我正在尝试创建一个 java 块,它允许我根据从数组调用的字符串调用类 - 但是,不幸的是,我似乎无法让它工作。如果有人可以提供帮助,我将不胜感激,我已经包含了到目前为止我已经散列的代码......
public class ProcrastinatorPanel extends JPanel {
String[] room = {
"Hallway", "Bathroom", "Study",
"Bedroom", "Dining Room", "Living Room",
"Kitchen", "Playroom", "Bathroom", "Garage" };
int roomNumber = 0;
public ProcrastinatorPanel() {
Hallway.hallway = new Hallway();
Class roomClass = Class.forName(room[roomNumber]);
}
}