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.
Cas
I think this will help you
Scanner input= new Scanner(System.in);
String readString = input.nextLine();
while(readString!=null) {
System.out.println(readString);
if (readString.equals(""))
System.out.println("Read Enter Key.");
if (input.hasNextLine())
readString = input.nextLine();
else
readString = null;
}
You can read line and if line is blank, You can assume it is enter key.. like below code..
Scanner scanner = new Scanner(System.in);
String readString = scanner.nextLine();
System.out.println(readString);
if (readString.equals(""))
System.out.println("Enter Key pressed.");
if (scanner.hasNextLine())
readString = scanner.nextLine();
else
readString = null;