String command = "";
        Scanner sc = new Scanner(System.in);
        while (command!="exit")
        {
            System.out.println("Please enter command: ");
            command = sc.nextLine();
            System.out.println("You enter: "+command);
            if (command == "exit")
            {
                System.out.println("Exit program.");
            }
        }
        sc.close();
Haven't written java in a year and I forgot how scanner work. The code would never enter the if part when I enter exit. I tried next() and nextLine().
 
    