/*
# Collection
Important interface that has methods like `add`, `remove`, `equals` and `size`.
http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html
Superinterface: `Iterable`.
Notable subinterfaces: `List`, `Set`.
Does not specify if ordered or unordered.
Array does not implement `Collection`.
Collection seems to be a well known non-Java specific computer science term:
http://en.wikipedia.org/wiki/Collection_%28abstract_data_type%29
# Collections vs arrays
Arrays are a Java feature like primitives,
that exists only to allow writing faster code
by mapping directly to hardware representations.
The tradeoff is that the array API is uglier and less flexible.
If you are not super concerned about speed, use collections by default.
http://stackoverflow.com/questions/6100148/collection-interface-vs-arrays
*/
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
import java.util.TreeSet;
public class CollectionCheat {
public static void main(String[] args) {
/*
# add Collection
Ensures that the collection contains the element.
Since collections can be either ordered or not,
this does not necessarily insert at the beginning or end.
Subinterfaces may specify that. E.g., `List` is ordered,
and List#add` always adds to the end of the list.
*/
{
/*
Return value: true if the collection was changed, false otherwise.
E.g. for List it is always true because duplicates are allowed.
But for Set it can be false since duplicates are not allowed.
*/
{
Collection