2. Array
Arrays are a way to store a list of items.
Each element of the array holds an individual
item, and you can place items into and remove
items from those slots as you need to.
Sample code of array:
String arr[] = new String[10];
arr[10] = “eggplant”;
3. Loops
A loop is a way of repeating lines of code
more than once. The block of code contained
within the loop will be executed again and again
until the condition required by the loop is met.
4. for loops
The for loops repeats the statement or the
block of the statements in many times until the
condition is matched
The syntax of for loop:
for (initialization; test; increment){
statements;
}
5. while loops
The while loops repeats the statement or
the block of the statements as long as the
condition is true
The syntax of while loop:
while (condition) {
bodyOfLoop;
}
7. If conditionals
The if conditional will enables you to executes the different
bits of code. If conditionals contain the keyword if, followed by
a boolean test, followed by a statement (often a block
statement) to execute if the test is true
Sample code of if conditionals:
if (x < y)
System.out.println(“x is smaller than y”);
An optional else keyword provides the statement to execute if
the test is false:
if (x < y)
System.out.println(“x is smaller than y”);
else System.out.println(“y is bigger.”);