[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

So sorry in advance about stupid stuff. I'm currently learning

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 12
Thread images: 1

File: IMG-20170423-WA0057.jpg (132KB, 1600x900px) Image search: [Google]
IMG-20170423-WA0057.jpg
132KB, 1600x900px
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 is
public 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
Thread posts: 12
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.