In the last few task i seen often this requirement:
The main method's first parameter is .....
I seen in some solution that corrispond at args[0], that should be the same array args that we can find in the main signature.
Someone can please explain me how works with that and why i should use it
Thankyou!
The main method's first parameter is
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Nouser
9 January 2021, 16:03solution
Some commandline programs you can start with additional parameters like gzip -d foo.tar.gz
For Java programs these parameters end up in the main methods args array. To simulate that with IntelliJ right click on the little green arrow next to the main method and select modify run configuration (or use the menu: Run -> edit configurations). Here you enter a path to your file in the 'program arguments' field.
+1
LennyMan
9 January 2021, 16:12
thankyou, i can't belive its never been explained in the course, now many excercise makes sense,
but still i don't get why we should use it.
0