Print a christmas tree class ChristmasTree
{
    private static void byHand()
    {
        System.out.println( &quot;Chritsmas tree, yey.&quot; );
        System.out.println( &quot;     *&quot; );
        System.out.println( &quot;    ***&quot; );
        System.out.println( &quot;   *****&quot; );
        System.out.println( &quot;  *******&quot; );
        System.out.println( &quot; ********&quot; );
        System.out.println( &quot;**********&quot; );
        System.out.println( &quot;    |&quot; );
        System.out.println( &quot;    _&quot; );
    }


    private static void withLoops()
    {
        int rows = 6;
        StringBuilder sb = new StringBuilder();
        for( int row = 0; row &lt; rows; ++row )
        {
            for( int spaces = rows - row; spaces &gt; 0; --spaces )
            {
                sb.append( &quot; &quot; );
            }

            for( int stars = 0; stars &lt; 2 * row + 1; ++stars )
            {
                sb.append( &quot;*&quot; );
            }
            sb.append( &quot;\n&quot; );

        }

        for( int spaces = 0; spaces &lt; rows; ++spaces )
        {
            sb.append( &quot; &quot; );
        }
        sb.append( &quot;|&quot; );
        sb.append( &quot;\n&quot; );
        for( int spaces = 0; spaces &lt; rows; ++spaces )
        {
            sb.append( &quot; &quot; );
        }
        sb.append( &quot;_&quot; );
        System.out.println( sb.toString() );
    }


    private static String spaces( int num )
    {
        StringBuilder sb = new StringBuilder();
        for( int spaces = 0; spaces &lt; num; ++spaces )
        {
            sb.append( &quot; &quot; );
        }
        return sb.toString();
    }

    private static String properly( int rows )
    {
        StringBuilder sb = new StringBuilder();
        for( int row = 0; row &lt; rows; ++row )
        {
            for( int spaces = rows - row; spaces &gt; 0; --spaces )
            {
                sb.append( &quot; &quot; );
            }

            for( int stars = 0; stars &lt; 2 * row + 1; ++stars )
            {
                sb.append( &quot;*&quot; );
            }
            sb.append( &quot;\n&quot; );

        }
        sb.append( spaces( rows ) );
        sb.append( &quot;|&quot; );
        sb.append( &quot;\n&quot; );
        sb.append( spaces( rows ) );
        sb.append( &quot;_&quot; );

        return sb.toString();
    }


    public static void main(String[] args)
    {
        byHand();

        withLoops();

        // What if the tree needs to be 100 lines high?
        // We arrive at the concept of `scalability`.
         System.out.println( properly( 16 ) ); 
    }
}

Topics I have considered but decided against:

pass the tree height on the command line via java.util.Scanner;
make a copy of spaces() called stars()
explain the purpose of the class at the very beginning a la python docstring
split the methods so the don't exceed 20 LOC

Also there's this.
I have some suggestions for your code.

Most of your loops can be replaced with java.lang.String#repeat (Java 11+)

Example
&quot;*&quot;.repeat(10) // Will give you &quot;**********&quot;


I suggest that you create a class constant for each of the tree's parts (*, \n, |) to allow the code to be easier to refactor / make changes in the future, if you need to (i.e., change the star by a plus sign, etc.).

For the tree's parts, I suggest that you use character instead of string, since the character will take less memory than the string (very small amount in this case, but still).
&quot; &quot; -&gt; ' '