I am trying to make a picture with an array filled with asterisks. The problem is, I have no clue how to make the asterisks appear in certain coordinates. If you could help that would be great.
public class Array {
public static void main (String[] args) {
horizontalLine();
}
public static void horizontalLine () {
String [][] anArray;
anArray = new String [2][8];
for (int i = 0; i < 2; i ++) {
for (int j = 2; j < 8; j ++) {
System.out.print ("*");
anArray [i][j] = "";
}
}
}
public static void picture () {
horizontalLine();
}
}
You solely have to assign the desired symbol to the array positions that you want (e.g.,
anArray [i][j] = "*";). Fill up the renaming array positions with spaces (e.g.,anArray [i][j] = " ";), or another symbol for that matter. Finally, after theanArrayis completely populated, print its content out.For example: