I can't figure out why this won't exit when quit is entered.

import java.io.*;
import java.util.*;

public class Trial
{

    static final String ADD_COMMAND = "add";
    static final String REMOVE_COMMAND = "remove";
    static final String QUIT_COMMAND = "quit";
    static final String PRINT_COMMAND = "print";
    
     // Create a single shared BufferedReader for keyboard input
        private static BufferedReader stdin = 
            new BufferedReader( new InputStreamReader( System.in ) );

        // Program execution starts here
        public static void main ( String [] args ) throws IOException
        {
            // Prompt the user
         
               System.out.print( "Type some data for the program: " );
            String input = "";
                        
            while(input != "quit")
            {

            // Read a line of text from the user.
             input = stdin.readLine();

            // Display the input back to the user.
            
            System.out.println( "input = " + input );
            
             }

         } // end main method


}

One question though. Are they any no no's about not using input.equals() or !input.equals() in such a thing.

use:
while(!input.equals("quit"))

instead of:
while(input != "quit")

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.