Can you help me in understanding the need of creating a new reference for hashmap slots named allSlots using the getter method? Considering we can use the class variable slots directly as this.slots.
|
final Map<Integer, Slot> allSlots = getSlots(); |
|
if (!allSlots.containsKey(slotNumber)) { |
|
allSlots.put(slotNumber, new Slot(slotNumber)); |
|
} |
|
return allSlots.get(slotNumber); |
Can you help me in understanding the need of creating a new reference for hashmap
slotsnamedallSlotsusing the getter method? Considering we can use the class variableslotsdirectly asthis.slots.lld-parking-lot/src/main/java/com/uditagarwal/model/ParkingLot.java
Lines 44 to 48 in 071f9a0