+ 1

What is the difference between these two codes in getting User Input in #java?

https://code.sololearn.com/c4391YB9pN5F/?ref=app https://code.sololearn.com/cM2PEew2bcRm/?ref=app

8th Jun 2017, 7:08 PM
Bilal Muhammed
Bilal Muhammed - avatar
4 Answers
+ 1
Nothing much, you just define the string earlier or later, but it both works
8th Jun 2017, 7:33 PM
Maart
Maart - avatar
+ 5
For one the scanner object is being initialized on creation of the class, the other is when ran in the main method. Both scanners are global objects in these examples.
8th Jun 2017, 7:40 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
@Maart Thanks! I am gratefull to you!
8th Jun 2017, 8:31 PM
Bilal Muhammed
Bilal Muhammed - avatar
+ 1
@Restoring faith, I appreciate it dude!
8th Jun 2017, 8:31 PM
Bilal Muhammed
Bilal Muhammed - avatar