Transcription of Collections in Java - Aalborg Universitet
{{id}} {{{paragraph}}}
OOP: Collections1 Collections in java ArraysnHas special language support IteratorsnIterator (i) Collections (also called containers)nCollection (i)nSet (i), uHashSet (c), TreeSet (c)nList (i), uArrayList (c), LinkedList (c)nMap (i), uHashMap (c), TreeMap (c)OOP: Collections2 Array Most efficient way to hold references to objects. AdvantagesnAn array know the type it holds, , compile-time type array know its size, , ask for the array can hold primitive types directly. DisadvantagesnAn array can only hold one type of objects (including primitives).nArrays are fixed : Collections3 Array, Example Helper class and sort: binarySearch(), sort()nComparison: equals()(many overloaded)nInstantiation: fill()(many overloaded)nConversion: asList()class Car{};// minimal dummy classCar[] cars1; // null referenceCar[] cars2 = new Car[10]; // null referencesfor (int i = 0; i < ; i++)cars2[i] = new Car();// Aggregated initializationCar[] cars3 = {new Car(), new Car(), new Car(), new Car()};cars1 = {new Car(), new Car(), new Car()};OOP: Collections4 Overview
OOP: Collections 1 Collections in Java • Arrays n Has special language support • Iterators n Iterator (i) • Collections (also called containers) n Collection (i) n Set (i), uHashSet (c), TreeSet (c)
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}