There are many solved multi-dimensional array posts, but I am having difficulties trying to create one through a for loop.
This is the code snippet of code that I am trying to do.
//Get a list of Person objects using a method
ArrayList<Person> people = getPeopleList();
//Create an array of 10 Objects with 4 values each
Object[][] data = new Object[10][4];
int count =1;
for(Person p: people)
{
//This wont compile. This line is trying to add each Object data with values
data[count-1][count-1] = {count, p.getName(), p.getAge(), p.getNationality()};
count++;
}
//I then can add this data to my JTable..
Can anyone tell me how I can create this multi-dimensional array using the for loop. I don't want a Person multi-dimensional array. It needs to be an Object multi-dimensional array? Thanks