Why does the language use .add() for some Collections and .put() for others. This seems inconsistent unless there is a good rea | Sololearn: Learn to code for FREE!

+2

Why does the language use .add() for some Collections and .put() for others. This seems inconsistent unless there is a good rea

son.

2/4/2017 1:09:45 PM

John Myers

2 Answers

New Answer

+6

.add() is a method used to add to a list, in things like arraylists and lists. .put() is used for maps and hashmaps to set a certain key to a value.

+2

Thanks, that makes sense. :-)