Java diamond with numbers I have an assignment to code a method that will print values in a diamond pattern. For example, if the method is called like printNumberDiamond(2), then the results should look like:

"  0  "
" 010 "
"01210"
" 010 "
"  0  "


I have spent a ton of time on writing the code that does this, but I am sure that it's not the most efficient/clean way. I am hoping to learn new strategies for accomplishing this, because this was very difficult for me to complete, and I almost just gave up, but I got it to work:

public static void printNumberDiamond(int diaCenter)
{   
        printNumberDiamondTop(diaCenter);
        printNumberDiamondBottom(diaCenter);
}


public static void printNumberDiamondTop(int diaCenter)
{
    int maxAscendingRows = diaCenter + 1;                       
    int maxColumnLength = diaCenter * 2 + 1;            
    int highestNbrForRow = 0;

    for(int row = 0, rowCtr=0;row&lt;=diaCenter;row++)
    {   
        int thisColumnLength = 0;
        int thisColumnMaxLeftSpaces = 0;        

        if(row &gt;= maxAscendingRows)
        {           
            thisColumnMaxLeftSpaces = (maxColumnLength - rowCtr) / 2;
            rowCtr--;           
        }
        else
        {
            thisColumnLength = maxColumnLength - row;   
            thisColumnMaxLeftSpaces = (thisColumnLength - row) / 2;
            rowCtr++;
        }

        int nbrWritten = 0;
        int nbrDescendingWritten = 0;           
        for(int col = 0;col &lt; maxColumnLength;col++)            
        {
            if(col &lt; thisColumnMaxLeftSpaces)           
            {
                System.out.print(" ");          
            }
            else if(nbrDescendingWritten == 0 &amp;&amp; nbrWritten &gt; row)  
            {
                System.out.print(" ");          
            }
            else if(nbrWritten &lt;= highestNbrForRow)     
            {
                System.out.print(nbrWritten++);     
                nbrDescendingWritten = nbrWritten - 1;                  
            }           
            else if(nbrWritten &gt; highestNbrForRow)
            {
                System.out.print(--nbrDescendingWritten);                   
            }                           
        }           
        ++highestNbrForRow;
        System.out.print("\n");
    }
}

public static void printNumberDiamondBottom(int diaCenter)
{               
    int maxColumnLength = diaCenter * 2 + 1;                        
    int highestNbrForRow = 0;                                       
    for(int row = diaCenter;row&gt;0;row--)
    {               
        highestNbrForRow = row - 1;
        int thisColumnMaxLeftSpaces = (maxColumnLength - highestNbrForRow * 2) / 2;
        int nbrWritten = 0;
        int nbrDescendingWritten = 0;

        for(int col = 0;col &lt; maxColumnLength;col++)            
        {
            if(col &lt; thisColumnMaxLeftSpaces)           
            {
                System.out.print(" ");          
            }
            else if(nbrDescendingWritten == 0 &amp;&amp; nbrWritten &gt; highestNbrForRow) 
            {
                System.out.print(" ");          
            }
            else if(nbrWritten &lt;= highestNbrForRow &amp;&amp; nbrWritten &gt;= 0)      
            {
                System.out.print(nbrWritten++);     
                nbrDescendingWritten = nbrWritten - 1;                  
            }           
            else if(nbrWritten &gt; highestNbrForRow)
            {
                System.out.print(--nbrDescendingWritten);                   
            }                           
        }           
        ++highestNbrForRow;
        System.out.print("\n");
    }
Before going into any coding I would give you a quick hack for the diamond problem . Instead of making so many for looping and columns and keeping track of variables the diamond problem is a variant of a maths problem. 
HERE 

1*1 = 1
11*11 = 121
111*111 = 12321
1111*1111 = 1234321 


and so on. SO if you use this formula you just need one for loop for spaces and one for increasing your num*10 +1 where num is 1 and then squaring it and you will get the diamond pattern. If you want I can code it for you but since you asked for an easier method this is the best you can get.