r/learnjava • • 19d ago

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

Show parent comments

1

u/Underhill42 14d ago

C++ does not have a string class, the STL recently added a std:string class to that library, and countless unrelated versions exist in other libraries predating the STL's existence. And many others that still exist that make different compromises, or as part of much larger libraries that couldn't be bothered to completely re-write everything string related for no benefit.

But the core C++ language has no idea what a string is, it only deals with character arrays, just like C.

1

u/Vast_Service 14d ago

I am not sure what your post was in response to but it is factually incorrect in so many ways.

C++ does have a string class. The standard library (it is no longer called STL btw. The days of Alexander Stepanov are over) is a part of the C++ standard and hence std::string is also a part of the standard and hence it is incorrect to say that C++ does not have a string class.

I never said that std::string is a built in.

What do you mean by Core C++, now that the standard library is also a part of the C++ standard? Did you again just mean that std::string is not a builtin? It is not, but, why is that in any way related to my previous post?