Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+18 votes

When I write a program, I accidentally put arg instead of args, and it still runs. There is no error.

asked in CSC211_Winter2018 by (1 point)

1 Answer

+9 votes

Technically you're just naming a variable there.

We usually name the variable args (which is short for "command line arguments"), but you could name it any other legal identifier (for example, String[] elephants, but that would be silly!).

So yes, your program will still work if you name the variable arg instead of args, but it's better to follow standard convention and make it plural.

answered by (508 points)
...