我想用掃描儀,使用戶在開關的代碼,我寫了使用一個數字:在java中switch語句中使用掃描儀
public class NewClass1 {
public static void main(String[] args) {
Scanner abd=new Scanner(System.in);
System.out.println("Enter a number");
int k = 5;
int k = i.nextInt();
switch (k) {
case 0:
System.out.println("You chosed 0");
break;
case 1:
System.out.println("You chosed 1");
break;
case 3:
System.out.println("You chosed 3");
break;
case 9:
System.out.println("You chosed 9");
break;
default:
System.out.println("Please enter something is in the list, Which is: 0,1,3,9.");
break;
}
}
我覺得有錯,還是在我的代碼失蹤,我會欣賞幫幫我。
任何錯誤,你越來越? –
是,int k = i.nextInt(); – Kaine
你得到的錯誤是什麼? – Shriram