String 无法转换为 char,如何解决?

String cannot be converted to char, how to fix it?

它说 "incompatible types: String cannot be converted to char" 如何解决? 这是例子。

这是您的解决方案:

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'

以外的任何内容