【发布时间】:2017-03-17 23:26:22
【问题描述】:
我的 java IDE 中有一些代码,我相信它支持控制台。我以前用过java,知道来龙去脉。但是,我以前没有出现过这个问题。我的代码如下所示:
Scanner scanner = new Scanner(System.in);
int choice = scanner.nextInt();
System.out.println("Choose a class.");
TimeUnit.SECONDS.sleep(10);
System.out.println("Press 1 for the a class.");
TimeUnit.SECONDS.sleep(10);
System.out.println("Press 2 for the b class.");
TimeUnit.SECONDS.sleep(10);
System.out.println("Press 3 for the c class.");
TimeUnit.SECONDS.sleep(10);
switch(choice) {
case 1:
playerClass.chosenClass = "a";
break;
case 2:
playerClass.chosenClass = "b";
break;
case 3:
playerClass.chosenClass = "c";
break;
default:
System.out.println("Null class. Please press 1-3 to choose a player class.");
}
}
我有所有的导入,playerClass 类确实存在。问题是,“System.out.println(String)”不起作用。
【问题讨论】:
-
我以前用过java,知道其中的来龙去脉——>进出之间好像少了点什么。
-
在提出新问题之前,请务必阅读minimal reproducible example 指导。 IE。对于这个问题,证明问题的 2 行可能会在不问问题的情况下向您展示问题所在。
-
知道了。但无法删除。
-
而且,Sundararaj,是的,可能是这样。我有一年没学过Java了。我想这是其中一项技能,如果不使用会随着时间的推移而退化。