BeginnerRudy / SWEN20003-OOSD-Shadow-Leap

Shadow Leap is a game project for the subject SWEN20003 Objected Oriented Software Development in 2018 semester 2.
0 stars 0 forks source link

Generic Type on the value of HashMap #2

Closed BeginnerRudy closed 6 years ago

BeginnerRudy commented 6 years ago

I want a hashMap with key to be String and the Value be the ArrayList of the subclass of Sprite.

BeginnerRudy commented 6 years ago

Eleanor said: Try using instanceof. You cannot have heterogeneous (multi-typed) HashMaps, but Java has other ways to deal with this situation.

BeginnerRudy commented 6 years ago

Sloved by down cast each to Sprite to specific subclass in order to invoke method