Printing a square - cant find the error
<p>The work I am currently doing requires me to 'draw' a square by printing '*' as the outline and '.' to fill it in. My code seems to work but it still isn't accepting it. I am a beginner, thanks. </p>

<pre><code>class Main {

    public static void main(String args[]) {

        int square = 5;
        int line = 1;
        int stars = 1;
        int startLine = square / square;

        while (line &lt;= startLine) {

            while (stars &lt;= square) { // first line prints out dots for the value of square, in this case 5
                System.out.print("*");
                stars = stars + 1;
            }

            System.out.println();
            line = line + 1;                //prints new line and adds 1 to line. Meaning it will move to the next section as it is now greater than startLine
        }

        stars = 1;              //resets stars

        while (line &lt;= square - 1) {// line will keep looping until its value is greater than square - 1

            while (stars &lt;= startLine) {
                System.out.print("*");         // First character to print is *
                stars = stars + 1;
            }

            while (stars &lt;= square - 1) {
                System.out.print(".");          //prints 3 dots
                stars = stars + 1;
            }

            while (stars &lt;= square) {
                System.out.print("*");         // stars is equal to square so 1 star is printed 
                stars = stars + 1;
            }

            stars = 1;
            System.out.println();
            line = line + 1;              // adds a value and loops around again
        }

        stars = 1;
        while (line &lt;= square) {

            while (stars &lt;= square) {
                System.out.print("*");
                stars = stars + 1;
            }

            System.out.println();
            line = line + 1;
        }
    }
}
</code></pre>

<p>It seems to make up the square and if I change the value of 'square' the size changes too. I cant see the problem.</p>
