using boolean to print invalid commands in java : I am trying to build my own command line interface.

most confusing part is that to print out the invalid command base on user input.

i tried using boolean function to each commands for its validity.

I want my program to continue even if my command is invalid.

**the question is , how do i get into a while loop again after i got out of it** 

        
        String command;
        

        BufferedReader console = new BufferedReader(new InputStreamReader(System.in));

        boolean R= true;

       
        while (R==true) {
        	
            
            System.out.print("command: ");

            
            command = console.readLine();
            R=false;

           
            ArrayList commandParams = new ArrayList();
            String[] commandSplit = command.split(" ");

           
            if (commandSplit.length > 1) {
             
                for (int i = 1; i < commandSplit.length; i++) {
                    commandParams.add(commandSplit[i]);
                }
            }

            
            if (commandSplit[0].equals("time")) {
                Date time = new Date();
                
                SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss ");
                System.out.println(sdf.format(time));
                R=true;
            }
            
            //Print today's date.
            if (commandSplit[0].equals("date")) {
                Date date = new Date();
               
                SimpleDateFormat sdf = new SimpleDateFormat(" YYYY/MM/DD");
                System.out.println(sdf.format(date));
                R=true;
            }
            
            //Exit the console when "exit" is entered.
            if (commandSplit[0].equals("exit")) {
                System.exit(0);
                R=true;
            }
            
        
        }
        System.out.println("invalid command");
        
        System.out.print("command:");
        command = console.readLine();
        
        
        
    }
}


