Do you think it is possible to create something similar to this?
private ArrayList increaseSizeArray(ArrayList array_test, GenericClass) {
array_test.ad
Old question but I would imagine this is the preferred way of doing it in java8+
public ArrayList dynamicAdd(ArrayList list, Supplier supplier) {
list.add(supplier.get());
return list;
}
and it could be used like this:
AtomicInteger counter = ...;
ArrayList list = ...;
dynamicAdd(list, counter::incrementAndGet);
this will add a number to the list, getting the value from AtomicInteger's incrementAndGet method
Also possible to use constructors as method references like this: MyType::new