Horje
java scanner string nextline after nextint Code Example
java scanner string nextline after nextint
//The problem is with the input.nextInt() method - it only reads the int value. So when you continue reading with input.nextLine() you receive the "\n" Enter key. So to skip this you have to add the input.nextLine(). Hope this should be clear now.

//Try it like that:

System.out.print("Insert a number: ");
int number = input.nextInt();
input.nextLine(); // This line you have to add (It consumes the \n character)
System.out.print("Text1: ");
String text1 = input.nextLine();
System.out.print("Text2: ");
String text2 = input.nextLine();
sc.nextline skips
int option = input.nextInt();
input.nextLine();  // Consume newline left-over
String str1 = input.nextLine();




Java

Related
javafx textarea how to make smaller Code Example javafx textarea how to make smaller Code Example
how to move a marker on google maps in android studio Code Example how to move a marker on google maps in android studio Code Example
java variable in string Code Example java variable in string Code Example
insert data into list java Code Example insert data into list java Code Example
HttpServer example java Code Example HttpServer example java Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8