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/
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.
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) )
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
also, it's way more sexy.
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.
>because /g/ said it's the best language
nigger, the only /g/ approved languages are scheme, common lisp and all the other lisp dialects