A better pyramid can be printed this way:
The Pattern is
$
$$$
$$$$$
$$$$$$$
$$$$$$$$$
$$$$$$$$$$$
public static void main(String agrs[]) {
System.out.println("The Pattern is");
int size = 11; //use only odd numbers here
for (int i = 1; i <= size; i=i+2) {
int spaceCount = (size - i)/2;
for(int j = 0; j< size; j++) {
if(j < spaceCount || j >= (size - spaceCount)) {
System.out.print(" ");
} else {
System.out.print("$");
}
}
System.out.println();
}
}