View on GitHub

reading-notes

Arrays, Loops, Imports

Packages and Import

Packages = Directory and it is a container of .java files. You can have import statements, which allow you to specify classes from other packages that can be referenced without qualifying them with their package.

Example:

package illustration;

import java.awt.*;

public class Drawing {
    . . .
}

There are 166 packages containing 3279 classes and interfaces in Java 5.

A Guide to Java Loops

Types of loops:
1- Simple for loop

A for loop is a control structure that allows us to repeat certain operations by incrementing and evaluating a loop counter.

2- Enhanced for-each loop

3- While loop

The while loop is Java’s most fundamental loop statement. It repeats a statement or a block of statements while its controlling Boolean-expression is true.

4- Do-While loop

The do-while loop works just like the while loop except for the fact that the first condition evaluation happens after the first iteration of the loop.