Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+17 votes
asked in CSC211_Winter2018 by (1 point)

1 Answer

+11 votes

I'm not sure what you're asking, but if you're trying to have the Scanner console store an entire String, then yes, you would use console.nextLine();. Alternatively, if you're trying to identify a token in a string, you could use console.next(); to store the next complete token.

Brief example:

String message1 = console.nextLine();
System.out.println(message1);
// "Hotdogs and Hamburgers!" --> Hotdogs and Hamburgers!

String message2 = console.next();
System.out.println(message2); 
// "Hotdogs and Hamburgers!" --> Hotdogs
answered by (1 point)
+5

yeah basically

...