Mam taki oto pragment kodu:
static ArrayList<Integer> limits = new ArrayList<>();
static HashMap<Integer, ArrayList<Ship>> ships = new HashMap<Integer, ArrayList<Ship>>();
public static Ship getShip(int size) {
.
.
.
if(ships.containsKey(size) && ships.get(size).size() < limits.get(size).intValue())
{
Ship ship = new Ship();
ships.put(size, new ArrayList<>());
ships.get(size).add(ship);
}
.
.
.
I moje pytanie brzmi czy za każdym wywołaniem metody getShip będzie tworzona nowa lista czy tylko wtedy, gdy jej nie będzie przy wartości size?