public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        try {
            while (scan.hasNextLine()){
                String line = scan.nextLine().toLowerCase();
                System.out.println(line);   
            }
        } finally {
            scan.close();
        }
    }
Just wondering how I can terminate the program after I have completed entering the inputs? As the scanner would still continue after several "Enter" assuming I am going to continue entering inputs... I tried:
if (scan.nextLine() == null) System.exit(0);
and
if (scan.nextLine() == "") System.exit(0);  
They did not work.... The program continues and messes with the original intention,
 
     
     
     
     
     
     
     
    