Slight Change

1. Jan 4, 2005

Hello all

My program is trying to print out a square but it is not working. I figure something is wrong with the spacing.

Code (Text):
public class Box
{
public void getBox( int a )
{
for( int i = 0; i < a; i++)
{
for( int j = 0; j < a; j++)
{
if( i == 0 || i == a-1)
System.out.print("x");
else
if( j == 0 || j == a-1)
System.out.print("x");
else
System.out.print( " " );
}
System.out.println( " " );

}
}
}

Any help is greatly appreciated

Thanks!

2. Jan 4, 2005

gnome

It should work. (In fact, it DOES work.) How are you invoking it?

3. Jan 5, 2005

ceptimus

How are you viewing the results? If the output is displayed in a non fixed width font, the spacing will appear wrong, even when correct.