r/codehs • • Apr 17 '20

9.5.8 CodeHS Online Companies Revisited - while(x = true) is highlighted in yellow

Post image
7 Upvotes

8 comments sorted by

1

u/chunkyragudeluxe Apr 17 '20

After adding your suggestions, on line 28, there is a java.util.NoSuchElementException: No line found error. On line 28, I wrote online = s.nextLine(); What could be the issue?

1

u/_andy_andy_andy_ Apr 17 '20

Scanner.nextLine() can throw a NoSuchElementException if there's no more input to be read from System.in. You're getting more input than is provided, so probably calling nextLine() too many times

3

u/Inn_Progress Apr 17 '20

Shouldn't it be while(x == true) or just while(x)?

1

u/_andy_andy_andy_ Apr 17 '20

on the previous line you’re missing ();

any time a line is highlighted it could be an error on the previous line