You're close.
If you look at my "hint" table again, you'll see a relationship between spaces and stars --
namely: (2 * spaces) + stars = what?
So, inside your outer for loop, just before your inner for loop, calculate spaceMax and use it in the for loop, then use this number and MAX (9) to calculate starMax:
Code:
public class Fu2 {
private static final int MAX = 9;
public static void main(String[] args) {
for (int i = 0; i < MAX; i++) {
int spaceMax = Math.abs(MAX/2 - i);
for (int j = 0; j < spaceMax; j++) {
System.out.print(" ");
}
int starMax = // [color="red"]*** use MAX and spaceMax to calculate this ***[/color]
for (int j = 0; j < starMax; j++) {
System.out.print("*");
}
System.out.println("");
}
}
}
Having said all this, you really don't need to use Math.abs, but instead could do all this with a simple if condition, but I think the Math.abs is cooler, and makes it easier to be able to create a diamond of any size.
Luck!