This is the first Chapter learning of Head First Java by Kathy Sierra and Bert Bates, This markdown
file is my notes for the first chapter, not sure if any copyright issues are there.
Syntax Fun:
-
Each statement must end in a semi colon.
x = x + 1;
-
A single line comment begins with two forward slashes.
//this line is a comment
-
Most white space doesn't matter.
x = x + 1;
-
Variables are declared with a name and a type.
int weight; //type: int, name:weight
-
Classes and methods must be defined within a pair of curly braces.
public void go(){ //some code }
There are three standard looping constructs:
- while
- for
- do-while
The important ingredient to a loop is the conditional test.
- The assignment operator uses one equals sign =.
- The equals operator uses two equals sign ==.
- A while loops runs everything within its block, as long as the conditional test is true.
- If the conditional is false, the while loop code block won't run, and execution will move to the code immediately after the loop block.