In this, part two of this ten part series on Java, Chris looks at the Java language syntax, variable declerations, truth conditions, loops and more. He finishes by wrapping everything up into a simple Java function.
In this, the second article of ten in the series, I will talk about the Java language syntax and other language related areas including variable declerations, looping, truth conditions and variable assignments.
Let's start with some basic Java language rules:
Each line of code must be immediately followed by a semicolon (;). The semi-colon must come before anything else or it will be considered by the Java compiler as being part of that line of code.
A variable should be declared before it is referred to in your code. Although in Java, it is not mandatory to do so, it does help to increase code readability if you do.
The Java compiler is not white space sensitive. White space is tolerated but must not be used within variable declarations. For example, variable_1 is valid as opposed to variable 1, which contains white space. Variable names should start with an alphabetic character, and can contain any combination of alphanumeric characters, including the underscore character.