我是初学者,请看以下内容:
public class CaseBreak {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int key = 1;
int dob = keyboard.nextInt();
switch(dob + key + 1)
{
case 1:
System.out.println("First switch");
break;
case 2:
System.out.println("Second switch");
break;
case 3:
System.out.println("Third switch");
break;
case 4:
System.out.println("Fourth switch");
break;
case 5:
System.out.println("Fifth switch");
break;
case 6:
System.out.println("Sixth switch");
break;
case 7:
System.out.println("Seventh switch");
break;
default:
System.out.println("Out of Switch! there is no");
}
}
}
以下一切运行良好。但是我想打印该数字以及当键盘输入超出大小写时调用的默认语句。像 ex- number 7 这样的东西进入默认状态,我得到“Out of Switch!没有”。我只是希望它也应该在语句之后出现数字(Out of Switch!没有 7)