[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]

Care to explain line be line how my simple program works /b/?

The stories and information posted here are artistic works of fiction and falsehood.
Only a fool would take anything posted here as fact.

Thread replies: 13
Thread images: 2

File: Japjeg.jpg (283KB, 700x544px) Image search: [Google]
Japjeg.jpg
283KB, 700x544px
Care to explain line be line how my simple program works /b/?


I just started learning java 3 hours ago because /g/ said it's the best language. So right now Java is getting more confusing so while i'm having this burning passion to learn something motivate me /b/
Learning is fun /b/
>>
Line 2 creates a class
Line 4 creates a void
Line 6 creates a for loop that loops from 1 to 11
Line 8 checks if looped number is even
Line 9 prints the number if it is even
>>
>>580380005
Java sucks, /g/ is fucking with you.

Regardless. The second line is required because in java everything has to be within a class. The curly brackets define the start and end of the class. Then line four begins a method. The main method is where actual execution begins, so lines 6 through 10 are the meat of your program. The for loop in line 6 executes lines 8 and 9 once for every number (call it i) up to ten starting from zero. Line 8 causes line 9 to execute if i is even. Line 9 prints the value of i.
>>
>>580380798
>The curly brackets define the start and end of the class

false. The curly brackets define the start and end of a block
>>
>>580380417
Nice simple explanation.
>>580380798
Thanks. So which programming language is worth learning than java?
>>
>>580380005
So, the first line declares a class. Every method has to be in a class in Java, for reasons you will later understand.

The second line is the so called "entry-point". This is what the system looks for when starting to execute your program. It always looks the same.

The third line is a loop, starting from the integer one, incrementing by one every iteration (i++) and then checking if it that counter is still below 11

The next line is called a condition. You check if your counter modulo two (thats the reminder of a division by two) is equal to zero, so in other words if you have an even number.

And then you tell the system to print "#: " + i, and append a newline (the difference between print and println(=printline) )
>>
>>580380005
the first line states you will never have a gf
>>
>>580381365
Java is a good starting point, but later you will want to get into some more advanced languages and concepts, if programming and learning is what you really enjoy.

As a step up I would recommend Scala because it runs on the JVM (the thing enabling your java code to run on linux and windows alike) and can therefore use any Java code and vice versa
>>
>>580380005
>the best language
Kek
>>
>>580381687
also, it's way more sexy.
Later, you will want to look into Python and JavaScript (just casually), Haskell (for the real understanding of functional programming), Go (as a C++ alternative) and Rust (because that's really interesting as well).

Languages aren't everything tho, so get to know your environments.

Best thing you can do: Learn Java enough to join a company, and everything else will fall into place.
>>
>>580380005
>because /g/ said it's the best language

nigger, the only /g/ approved languages are scheme, common lisp and all the other lisp dialects
>>
>>580381961
Kek
>>
>>580381903
Thanks for the great advice. I'll follow that advice.
Thread posts: 13
Thread images: 2


[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.