0
I'm stuck on this Scanner code can you help me? Particularly on the line String color = userInput.nextline();
import java.util.Scanner; public class Program{ public static void main(String[] args) { Scanner userInput = new Scanner (System.in); //initializes scanner System.out.println("What is your favorite color"); //user inputs color String color = userInput.nextline(); System.out.println(color + " " + "That is a lovely color!"); //prints out statement } }
4 Respostas
+ 19
Well, it should be
String color = userInput.nextLine();
// l uppercased :)
+ 11
Use capital L for nextLine() :)
0
Thanks so much. I really don't understand the error messages they're so vague.
0
A 'color' is what I would expect a user to input, but any answer works. Is there a way to limit the answer to colors