The problem I am having is when I print out horizontalLine(1, 1, 3, 1)
it adds the horizontalLine before it into the console. Is there any way to stop the duplication?
public class Array {
static String arrayPicture[][];
public static void main (String[] args) {
arrayPicture = new String [5][5];
for (int i = 0; i < 5; i ++) {
for (int j = 0; j < 5; j ++) {
arrayPicture [i][j] = " ";
}
}
horizontalLine (0, 0, 4, 0);
horizontalLine (1, 1, 3, 1);
}
public static void horizontalLine (int x1, int y1, int x2, int y2) {
for (int k = x1; k < x2; k ++) {
arrayPicture [y1][k] = "*";
}
picture();
System.out.println ();
}
public static void picture () {
for (int i = 0; i < 5; i ++) {
for (int j = 0; j < 5; j ++) {
System.out.print (arrayPicture[i][j]);
}
}
}
}