public class ForLoops
{
public static void main(String[] args)
{
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 6; j++)
{
if(i==0 || i == 4)
{
System.out.print("O");
}
else if(j == 0 || j == 6)
{
System.out.print("O");
}
else
{
System.out.print(" ");
}
}
}
}
}
I have to make a square that is 6x4 that looks like this:
OOOOOO
O O
O O
OOOOOO
OOOOOO
OemptyO
OemptyO
OOOOOO (empty) = empty spaces, blanks.
which i is the row(4) and j is the column(6)
and it is just not coming out right. I am also new to Java.

New Topic/Question
Reply



MultiQuote



|