JAVA的if语句怎么把输入的一个字符作为判断条件?

2025-03-23 03:37:00
推荐回答(1个)
回答1:

char c =sc.next().charAt(0);
while(true){
if(c=='c'||c=='d'){
System.out.println("请输入字母:");
c =sc.next().charAt(0);
}else{
break;
}
}