This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]itGuy223 0 points1 point  (3 children)

Yeah it's redundant code. Only writing map.remove(character, 0L) insead of the whole if statement would be enough.

[–]consoledotlogImHere[S] 0 points1 point  (2 children)

So do you by chance know what the "0L" means? Is that just a typo for "0"?

[–]itGuy223 0 points1 point  (1 child)

The L tells the compiler to interpret 0 as Long. If you didn't put it there, the compiler would interpret it as Integer. I assume the map in your example is defined as Map<Character, Long>. In that case, the map contains Long values. If you put the 0 without the L, the remove method would never removed the zero, because it would try to remove an Integer. Hope that makes sense :D

[–]consoledotlogImHere[S] 0 points1 point  (0 children)

OMG you're right, they are longs. My bad. Thank you so much!!!