0

I am trying to get my code to keep repeating asking if I want to end my code while "input" is y, but whenever I press y to continue it ends. I am not sure what I am doing wrong here. Is my logic off?

import java.util.*;

public class InputValidation {
   public static void main(String []args) {
      String input = "y";
      while (input == "y") {
         Scanner console = new Scanner(System.in);
         System.out.print("Press \"y\" to continue, anything else to end ");
         input = console.next();
      }
   }
}
sidfvdx125
  • 15
  • 5

0 Answers0