Transcription of Collections in Java - AAU
{{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
OOP: Collections 2 Array • Most efficient way to hold references to objects. • Advantages n An array know the type it holds, i.e., compile-time type checking. n An array know its size, i.e., ask for the length. n An array can hold primitive types directly. • Disadvantages n An array can only hold one type of objects (including primitives). n Arrays are fixed size.
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}