import java.util.Scanner;
public class mainClass{
static public Scanner keyboard = new Scanner(System.in);
public static void main (String [ ] args)
{
anotherMethod();
}
static public void anotherMethod()
{
String sentence;
String answer;
do{
System.out.println("Lets read a sentence: ");
String Sentence = keyboard.nextLine();
System.out.println("The sentence read: " + sentence);
System.out.println("Do you want to repeat?");
answer = keyboard.next();
} while (answer.equalsIgnoreCase("yes");
}
}
The result is that after the first run, the program displays "Lets read a sentence:"
and also "The sentence read: "
without letting me enter a sentence..
I would like to know the simple way of solving this problem.