Why does the top print 5 and the sides print 4 and bottom print 3 lines. this program prints a box made out of lines with a empty interior and the out put is shown below.

int size = 5;for (int row = 0; row < size; row++) { for (int col = 0; col < size; col++) { if (row == 0) { System.out.print('-'); } else if (col == 0) { System.out.print('|'); } else if (col == (4)) { System.out.print('|'); } else if (row == (size - 1)) { System.out.print('-'); } else { System.out.print(' '); } } System.out.println();}-----| || || ||---|

Check Solution