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