1. Flow of Control
if - else statements.
//Syntax
if(Boolean_expression)
YES_Statement
else
No_Statement
Mutiway if-else statement
//Syntax
if(Boolean_expression1)
Statement_1
else if(boolean_expression2)
Statement_2
else if(boolean_expression3)
Statement_3
....
else
Statement_FOR_ALL_Other_Possibilities
switch statement
//Syntax
switch(Controlling_Expression)
{
case Case_label_1:
Statement1
break;
case Case_label_2:
Statement2
break;
....
case Case_labeln:
statementn
break;
default:
default_statementn
break;
}
The Methods equals and equalsIgnoreCase
When testing strings for equality, do not use ==, Instead, use either equals or equalsIgnoreCase.
//Syntax
String.equals(Other_strings);
String.equalsIgnoreCase(Other_String);
Since all strings does not test to see whether the strings are equal. Instead, it tests whether two strings refer to the same object.
So, to test two strings to see if they have equal values, we should use the method equals rather than ==.
2. Loops
while Statement and do-while Statement
//a while Statement
while(Boolean_expression)
{
Statement(s)
}
//A do-while statement
do{
Statement(s)
}while(Boolean_Expression);
The for Statement
//Syntax
for(Initialization; Boolean_expresssion; Update){
Body
}