I am trying to create an array of a class within a class so that I can have multiple sets of the inner class. However because I cannot create an empty an array in Java, I was wonder what's the best way to set this up. I know I can just define an array that is bigger than I would ever use but I feel that kind of sloppy programming.
Here's the important part of the 2 classes:
public class xmldata {
String Barcode;
String First;
String Last;
String Phone;
String Email;
String md5sum;
String zipfile;
picture_data[] pics;
...
public class picture_data {
static String filename;
static String directory;
As you can see, I to have an array of picture_data in xmldata. I have seen some stuff using lists but the examples are different and I am not sure I understand how to apply it in my case.
Here's the code I used to try and populate the arrays.
xmldata data = new xmldata();
ResultSet pictures=db.query("select * from pictures where barcode=?",barcode);
int i = -1;
while (pictures.next()) {
++i;
data.pics[i].setdirectory(pictures.getString("path"));
data.pics[i].setfilename(pictures.getString("filename"));
}
Any suggestions would be appreciated.