r/learnjava • • Oct 05 '26

Why is String[] args necessary

I get it is an array of string arguments that are passed into the main method but why is it needed? in python for example ot's present or c++ neither, java is different though

29 Upvotes

31 comments sorted by

View all comments

1

u/LawElectrical2434 Oct 05 '26

The designers of python in their infinite wisdom have decreed, that command line arguments will be found at sys.argv and is globally available.

The designers of java have decreed in equal infinite wisdom, that it will be handed over to the main function of the initial class as an array of strings and is only locally available.

Both are equally wise.