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
3 Respuestas
+ 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);
}
...
}
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.
0
Found it!
"
Read a complete line - nextLine()
Read a word - next()
"
Thank you