I am in a beginner java programming class and currently reviewing loops. If there is one thing I just do not understand, it\'s pyramids. I have researched the book exercis
public static void main(String[] args) {
// levels in the pyramid
int x = 5;
for (int i = 1; i <= x; i++) {
// for spacing
for (int j = 1; j <= x - i; j++){ System.out.print(" "); } // left half of the pyramid for (int k = i; k >= 1; k--){
System.out.print((k >= 10) ? +k : " " + k);
}
// corresponding right half of the pyramid
for (int k = 2; k <= i; k++) { System.out.print((k >= 10) ? +k : " " + k);
}
// next line
System.out.println();
}
}
Credit: http://www.skilledmonster.com/2013/10/28/java-pyramid-example-pattern-11/