我遇到的问题是当我打印出来时,horizontalLine(1, 1, 3, 1)
它会在它之前添加水平线到控制台中。有什么办法可以阻止复制吗?
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]);
}
}
}
}