title: How do I make a if-else statement with the string argument ( that is a string input from the user)?
body: <p>I am writing a program that asks the user to input his name, address and phone number. When the data is entered the program shall print the data and ask the user to verify the data by entering YES or NO. This process shall be repeated until the user is satisfied and answers YES to the question.</p>
  
  <p>Now in my case I may have put a if-else statement inside the while loop in an inappropriate way. That's why it's not working as it is expected to be. <strong><em>How can I solve this?</em></strong></p>
  
  <p>Also I only have tried the promt asking to enter the users name. <strong><em>But if I want to add more prompt with different question in the similiar way then how could I do that?</em></strong></p>
  
  <p>Code:</p>
  
  <pre><code>package userinfo;    
  import java.util.Scanner;
  
  public class UserInfo {
  
      public static void main(String[] args) {    
          String name;
          String yes = "YES";
          String no = "NO";    
          Scanner userInput = new Scanner(System.in);
  
          System.out.println("Enter your name:");
          name = userInput.next();
          System.out.println("Please varify your name by typing YES or NO");
  
          while (true) {
              String input = userInput.next();
              if (input == yes) {
                  System.out.println("Your name is: " + name);
              }
              if (input == no) {
                  System.out.println("Enter your name again");
  
              } else {
                  System.out.println("Invalid input! Enter value again:");
                  break;
              }    
          }    
      }    
  }
  </code></pre>