Chapter 13 Flashcards
In programming, ______ is a group of objects that can be operated on together.
Collection
A difference between a collection and an array is that a collection
Is dynamically resizable
The Java Collections framework contains
Both interfaces and classes
The List interface
Allows items to be inserted after creation
an advantage of using the ArrayList class over the Arrays class is that an ArrayList
Is dynamically resizable
An ArrayList can hold
Any object type
The number of items an ArrayList can hold is its
Capacity
Legal method calls of ArrayList of Strings is
MyString.add(“onion”);, int s = myString.size();, and myStrings.add(0, “leek”);
An ArrayList with a capacity of 10 and six elements are assigned
Number.set(1,55);, number.get(5);, and number.add(77) are legal
When you create a class from which you will instantiate objects to store in an ArrayList,
You are not required to create either a toString() method or a compareTo() method
The method that can be used to sort an ArrayList is
Collections.sort()
Integer, String, and Double all have _____ built-in
CompareTo() method
If you want to use Collections.sort() with a class you have created, you must
Write your own compareTo() method
Requirements when you create a compareTo)_ method that overrides the Object class compareTo() method are
It must accept a parameter, it return type should be int and return -1,0,1, and it must be named compareTo()
The ArrayList class works better than a LinkedList when you
Have to sequentially retrieve a lot of data