Skip to content

Need of creating a refrence to hashmap #4

@amarlearning

Description

@amarlearning

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions