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!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

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

son.

4th Feb 2017, 1:09 PM
John Myers
John Myers - avatar
2 Answers
+ 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.
4th Feb 2017, 3:58 PM
NickB
NickB - avatar
+ 2
Thanks, that makes sense. :-)
4th Feb 2017, 3:59 PM
John Myers
John Myers - avatar