There are many permitted multidimensional array messages, but I'm having difficulty trying to create a single for loop.
This is the code snippet of the code I'm 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 someone tell me how I can create this multidimensional array using a for loop. I do not want a multidimensional array of Person. Should it be a multi-dimensional array of Object? Thanks
source share