# Slight Change

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:
 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!

Related Computing and Technology News on Phys.org

#### gnome

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

#### 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.

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving