I have an ArrayList that is not vary memory intensive, it stores only two fields,
public class ExampleObject{
private String string;
private Integer integer;
public ExampleObject(String stringInbound, Integer integerInbound){
string = stringInbound;
integer = integerInbound;
}
I will fill an ArrayList with this objects
ArrayList<ExampleObject> = new ArrayList<ExampleObject>();
for raw, hard core performance is it much better to use a hashset for this? If my ArrayList grows to a vary large number of items with an index in the the hundreds, will I notice a huge deference between the ArrayList of Objects and the hashset?
It all depends on what you’re doing. How is data added? How is it accessed? How often is it removed?
For example, in some situations it might even be better to have parallel arrays of
String[]andint[]— you avoid collection class overhead and the boxing ofinttoInteger. Depending on exactly what you’re doing, that might be really great or incredibly dumb.Memory consumption can have a strong effect on performance as data sets get larger. A couple of IBM researchers did a neat presentation on Building Memory-efficient Java Applications a few years back that everyone who is concerned about performance should read.