Lecture 7 Flashcards
What are containers (In java)?
Containers are groups of data, much like arrays.
What is the difference between arrays and containers?
Containers have a flexible size, arrays do not.
What are the biggest pros and cons of containers compared to arrays?
pro: more flexible
con: less efficient
What is the order of an algorithm?
The order of an algorithm is a measure of the algorithm’s execution time. Determined by the order of the number of steps it takes, e.g. O(1), O(n), O(n^2).
What differentiates a set from a list?
In a set, there is no specific order and there cannot be duplicate elements. In a list, there is a specific order and there can be duplicate elements.
What happens if you add 23 to an ArrayList, how is this called and why?
It will be stored but as an object of the class Integer. This is called auto-boxing and the reason for this is that an ArrayList can only contain elements that are of a reference data type.
How can you specify the class of objects in an ArrayList?
ArrayList someArray = new ArrayList(); AND BRACKETY THINGIES! <>