I'm trying to add a new Entry object to an array of objects. I don't know how I would go about writing a method to do this. Also I'd like to increase the size of the array as new elements are added to it.
public class Entry {
private String surname, initial, extension;
public Entry() { }
public Entry(String surname, String initial, String extention) {
this.surname = surname;
this.initial = initial;
this.extension = extention;
}
}
I want to write the method to add the elemets to the array here. The new Entry object is currently hard coded but this will obviously be altered.
public class ArrayDirectory implements Directory {
Entry[] entries = new Entry[4];
public void addEntry(Entry newEntry) {
newEntry = new Entry("isajas","ssds", "sasdas");
}
}
Thank you for taking the time to read my question!
ArrayList<Entry>rather than rolling your own dynamic array?