Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
I'll assume Java because that's what you've been learning. There are many cases where we don't want to deal with a single object in code, but multiple (probably related) objects. An array is like a collection, because you can store multiple objects in it and pass the array around. The Collections API in Java is useful for various types of collections, and different data structures that might be suitable for our application. https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html This page documents the Collection interface, notice too the subinterfaces like List, Set etc. They too have subclasses implementing LinkedLists, SortedSets, TreeSet etc. and all the documentation is here. The most common use for collections is to add/remove and iterate through its elements. Practice makes perfect but make use of the docs too as it helps you use new methods you didn't know about
31st Aug 2018, 6:58 AM
Dan Walker
Dan Walker - avatar