How to capture enter key, using scanner as console input?
I want to capture enter character in console. I am inputting 2 strings. Case 1. removestudent(pressing enter) removes all the students from array list. Case 2. removestudent student1 removes students1 from array list. Scanner in=new Scanner(); type_op=in.next(); param=in.next(); if (type_op.equals("removestudent")) { //Calling remove student function and passing param over here. } Now the case 2 works fine. However, for Case 1, I want param value to be null when user presses enter. I will then pass param as a null value to my remove function and delete all the students in the array list. list1