I need get a String from prompt, and juste after I need get a String list from prompt. I have a problem. When I get my list, I have only the first word. I try any other nextLine()
... but do not work. I see lot of sample with juste 2 words (one space) but i looking for a list of word!!
Java code:
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter a name:");
String name = input.next();
System.out.println("Enter a name list:");
String nameList = input.next();
System.out.println("Enter last name:");
String lastName = input.next();
input.close();
System.out.println(name + " * " + nameList + " ** " + lastName);
}
console result:
Enter a name:
aa
Enter a name list:
bb cc dd
Enter last name:
aa * bb ** cc
1st response is aa + enter
2nd response is bb cc dd + enter
but juste after dd + enter, the program display Enter last name:
aa * bb ** cc
and stop