Syntax

Structure

Each statement ends with a semi-colon (;)

Statements are grouped in blocks enclosed in braces ({})

//
Start of comment, ending with the EOL
/*…
….*/
Comment over more than one line
break
Stop a loop command immediately
continue
Stop the current loop execution,  continue  with  the next step.

break
Stop a loop command immediately
continue
Stop the current loop execution,  continue  with  the next step.
for
for (init; condition; update) {
statements;
}
for (a=0; a<10; a++) {
statements;
}
if
if (condition) {
statements
} else if (condition) {
statements;
} else {
statements;
}// The ‘else if’ and ‘else’ parts are optional.

while
while (condition) {
statements;
}
do-while
do {
statements;
} while (condition)
switch
switch (condition) {
case ABC: {
statements;
}
/* fall through */
case DEF: {
statements;
}
break;
default: {
statements;
}
break;
}
try.. catch
try {
statements;
}
catch (ErrorType1) {
statements;
}
catch (ErrorType2) {
statements;
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.