Reputation: 35
I have a String array:
String[][] array = new String[7][6];
And I want to auto-fill everything with "[]"
, with one loop to basically set a default value. I tried to use Arrays.fill
but it didn't work out well.
Upvotes: 1
Views: 60
Reputation: 77
This will work for you if you want it in one loop.
String[][] myArray = new String[7][6];
int i, j;
for(i=0; i<7; i++)
{
j=i;
myArray[i] [j]= " ";
j++;
myArray[i] [j]= " ";
j++;
myArray[i] [j]= " ";
j++;
myArray[i] [j]= " ";
j++;
myArray[i] [j]= " ";
j++;
myArray[i] [j]= " ";
}
Upvotes: 0