String Cannot Be Converted to Char, How to Fix It? [Closed]

It says "incompatible types: String cannot be converted to char" How to fix it? Here is the example.

13

This is your solution :

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

    }
}

To exit enter any thing other then 'Y'

0
Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest