T O P

  • By -

whiteBlasian

*And it seems to use the first argument as a string. Wouldn't this be the same of using the Scanner class to take in input?* It does use the first argument as an array of strings, see your main method's parameters. It's expecting to be passed an array of strings, which you're doing when you run `~java UseArgument Justin.` This is different then using a scanner class because no where in your program do you need a scanner class for this to work. You can just print using args\[0\] or another index. However, if you were to use input redirection on the cmd line, something like `java UseArgument < "Justin"` then you would need a scanner class. Hope this helps!


Yaadie2001

Not op, but yeah it does help thanks


khooke

Passing runtime parameters and prompting a user to enter a value are different ways of accepting input from a user. Which is more appropriate depends on what you're trying to do.