0

I need to read a string on a while loop, it works with sc.next(and it can only read 1 word) , but with a nextLine it skips the instruction and asks for the doubles.

Scanner sc = new Scanner(System.in);
while(i < test) {
    System.out.println("Test name");
    testName = sc.nextLine(); //does not work
    System.out.println("Time obtained");
    System.out.println("Hours");
    hours = sc.nextDouble();
    System.out.println("Minutes");
    Min = sc.nextDouble();
    System.out.println("Seconds");
    Sec = sc.nextDouble();
}
Federico klez Culloca
  • 22,898
  • 15
  • 55
  • 90
ADGJ20
  • 11
  • 3

0 Answers0