0

Java tuitorial - basic concepts, getting user input - drag and drop question

Greetings, In the Java tuitorial - basic concepts, getting user input - drag and drop question, I dont understand the answer and I wanted to know if the word 'next' is a special Java operator like 'scanner' is? Would like to understand why 'nextLine' was the correct choice? Kind regards BcE

18th Apr 2019, 12:10 AM
Blockchain Economy
3 Answers
+ 1
Drag and drop to create a component that logs the value of the "name" state variable when it gets updated. Answer class Test extends React.Component { state = { name: "Test" } componentDidUpdate() { console.log (this.state.name); } ... }
21st Nov 2020, 2:44 PM
Jason Chew
Jason Chew - avatar
0
Both next() and nextLine() are methods of the Scanner class. If you take a look at the example given in the tutorial (right after listing some methods included in the scanner class), it uses nextLine() to get input from the user. https://www.sololearn.com/learn/Java/2220/ Next() stops getting input if the user enters a space while nextLine() only stops when the carriage return/enter key is pressed by the user.
18th Apr 2019, 12:37 AM
Lambda_Driver
Lambda_Driver - avatar
0
Found it! " Read a complete line - nextLine() Read a word - next() " Thank you
23rd Apr 2019, 4:26 AM
Blockchain Economy