【发布时间】:2026-02-12 04:50:01
【问题描述】:
我对 Java 很陌生,如果我的问题太简单了,我很抱歉,但由于我找不到 switch 语句从未执行的原因,所以我仍然被阻止。 代码如下:
static void findSpot(String[][] parking) {
boolean control = false, repeat;
System.out.println("Insert o Floor : Spot");
Scanner s = new Scanner(System.in);
String[] floorSpot = s.nextLine().split(":");
int floor, spot;
floor = Integer.parseInt(floorSpot[0]);
spot = Integer.parseInt(floorSpot[1]);
if (floor >= parking.length) {
System.out.println("Invalid floor number!");
}
System.out.println("Insert registry: 00-00-AA 00-AA-00");
String registry = s.nextLine();
repeat = validateRegistry(registry);
if (!repeat) {
System.out.println("Invalide format.");
}
}
【问题讨论】:
-
请同时显示(完整的)堆栈跟踪。
-
代码中没有 switch 语句....
-
@MichaelBerry 它确实解释了为什么它没有被执行:)
-
@Stultuske 绝对。我当然希望我的代码很容易调试 ;-)
-
@paul 您的代码仍然不完整。它没有显示它是在哪个方法中,那么我们如何知道它是如何调用的,或者使用哪些参数?
标签: java