Easy Tutorial
❮ Java Enumeration Interface Method Label ❯

Java Example – Printing a Rectangle

Java Example

Output a rectangle.

Example

public class Rect {
    public static void main(String[] args) {
         // Outer loop to print each row of asterisks
        for (int i = 1; i <= 5; i++) {
            System.out.print("*");
            // Inner loop to print each asterisk in the row
            for (int j = 1; j <= 5; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}

Output result:

******
******
******
******
******

Java Example

❮ Java Enumeration Interface Method Label ❯