0

Hello, I have this little piece of code

System.out.println("Write a sentence: ");
    String sentence = tastatur.next();
    String[] temp;
    String divider = " ";
    temp = sentence.split(divider);

The problem is that when I enter a sentence only the first word gets stored in the string. For instance if I enter "dum di du", only "dum" will get stored. How can I solve this so the whole sentence gets stored in the string?

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by java.util
0

Nevermind, I figured it out. I needed to put tastatur.nextLine() in line 2.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.