Java : Logic and Operations, control and repetition statements
if(){}else{}
and switch(){case:}
statements
while
loop
// while
int size = 10;
int i = 0;
while (i < size) {
//Some repeated instruction
i++;
}
do-while
loop
// while
int size = 10;
int i = 0;
do{
//Some repeated instruction
i++;
} while (i < size);
for
loop
// for-loop
String[] table = new String[10];
for (int i = 0; i < 10; i++) {
String current = table[i];
System.out.println(current);
}
// for-loop, "foreach" way
for (String s : table) {
System.out.println(s);
}
//Declares a table of 10 strings
String[] table = new String[10];
int tableLength = table.length;
//Accesses the occurrence at the first index
String occurrence = table[0];
Factorial
static void main
method calling all the three methods with parameters