Java Examples – Print Rectangle
Output a rectangle.
Example
public class Rect {
public static void main(String[] args) {
//Outer loop: output one line of * each time
for (int i = 1; i <= 5; i++) {
System.out.print("*");
//Inner loop: output one * each time
for (int j = 1; j <= 5; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
Output result:
****** ****** ****** ****** ******Other Extensions
Java Examples