java - Create Dynamic Array with fixed number of columns -


i need create 2 dimensional table know number of columns don't know number of rows. rows generated through code , added table. question is, data structure in java think best these features?

you should create class field each of columns. example, here person class.

public final class person {      private final string firstname;     private final string lastname;     private final int age;      public person(string firstname, string lastname, int age){         this.firstname = firstname;         this.lastname = lastname;         this.age = age;     }      public string firstname() {         return firstname;     }      public string lastname() {         return lastname;     }      public int age() {         return age;     } } 

then can create arraylist<person>. number of rows increased needed.

for example

list<person> table = new arraylist<>(); table.add(new person("john", "smith", 52); table.add(new person("sarah", "collins", 26); 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -