0

Scanner can't convert to String

So this I found interesting. I want my input to be a string I can work with, but I get errors when working with it. So I thought it isn't properly a string, hence it can't be worked with. On attempt to make it legit a string, it says no. SoloLearn says this is the most popular form of input, is there something else? class In { public static void main(String[ ] args) { System.out.println ("What is your name?"); Scanner myVar = new Scanner(System.in); // String name = myVar; System.out.println(myVar.nextLine()); } }

29th May 2018, 7:03 PM
Michelle
Michelle - avatar
3 Respostas
+ 4
The Scanner Object has functions for getting input, it isn't the input itself
29th May 2018, 7:05 PM
Jonas Schröter
Jonas Schröter - avatar
+ 4
I know your problem is solved but here is the doc for the Scanner class and it contains all the methods that can be used on a Scanner object... Get used to using the Java (or any language) docs. They are an invaluable source of information. https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
29th May 2018, 8:23 PM
cyk
cyk - avatar