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
  • 7,638
  • 19
  • 69
  • 90
Sanath Kumar
  • 143
  • 11

0 Answers0