So sorry in advance about stupid stuff.
I'm currently learning Java after sort of learning the basics of Python, it's going okay so far, but after some readings, I still don't understand why ispublic class EbinClass {
public static void main(String[] args)
necessary in every code, I'd appreciate some knowledge.
>>60177797
I dont know but it seems that java classed based
and is thus boilerplate-y by heart
false flag.
please go back to masturbating over SICP.
>not knowing the significance of every modifier
>not realizing that main is the starting point
>not making the connection that args is the command-line arguments
wew lad, you're not trying to make this a career are you?
>>60177831
Im new to java but what's the point of the class statement?
I take it for packaging or compiling requirements?
>>60177797
some object-oriented languages like Java and C# require any code to exist within classes. as far as I know, it's purely a language spec thing done either for consistency or to enforce the practice of structuring your program around, well, objects.
this might not make sense until you actually understand what an object or a class are, and how object-oriented programming works. I suggest you keep on learning and eventually everything will click.
>>60177797
What you are looking at is the main function, it's the function the system outside your program tries to call when starting your program.
Java requires all functions to reside within a class for consistencies sake. So that's why there's a class.
The class/function must be declared public so that they can be accessed from outside the context of the file/class (so the system can get at it).
The function is static because there is no way for an instance of your class to exist prior to the calling of the main function (Well there is, but we're going to ignore it for now). Therefore if the main function is going to be called, it must be static.
The function returns void because it doesn't need to return anything (Shut up C people, I'm fully aware).
The function takes an array of strings as an argument because that's how you pass arguments to something on the command line. Anything you provide as a command line argument will end up in there.
>>60177927
>>60178009
Thank you guys! It's starting to makes sense
>>60178009
>Java requires all functions to reside within a class for consistencies sake. So that's why there's a class.
Why!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>>60178041
To encourage you to adhere to Java ideology I think. C# does it as well. I always end up with a Tools class full of miscellaneous string/time/print tools myself.
>>60177865
>I take it for packaging or compiling requirements?
It's this. Everything in Java must be contained within a class (or variations on a class like an interface)
There's no modules or namespaces either, classes serve that puprose.
Java is old and deracated, learn rust instead