0

I don't understand why the program doesn't come out of the loop even after the value of variable YoN is entered as "N".

Output:

code:

import java.util.Scanner;
public class JavaLessonFour{
    static Scanner s = new Scanner(System.in);
    public static void main(String[] args) {    
        String YoN = "Y";
        while(YoN != "N")
        {

            System.out.println("inside");
            YoN = s.next();
        }
    }       
}
Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Sanath Kumar
  • 163
  • 1
  • 12

0 Answers0