字符串不能转换为字符,如何解决它?
答
这是您的解决方案:
public class NewMain {
public static void main(String args[]) throws ParseException {
Scanner s = new Scanner(System.in);
char yes;
do {
System.out.println("Hi");
yes = s.next().charAt(0);
} while (yes == 'Y'); // if u enter 'Y' the it will continue
}
}
要退出进入其他任何东西,然后'Y'
+0
好的,谢谢 –
宣布你们CHAR是作为字符串。 –
我强烈建议您先阅读基础知识 –
如何将其声明为字符串?我是初学者 –