- Type Parameters:
Item
- the item type
- All Implemented Interfaces:
Container<Item>
An array-based container.
Contains some number of items using an array.
-
Constructor Summary
Constructors
Construct an empty array.
Construct an array containing the given items.
-
Method Summary
boolean
Check if the given item is equal to any of those contained.
int
Get the number of contained items.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Array
public Array()
Construct an empty array.
-
Array
Construct an array containing the given items.
- Parameters:
items
- the items
-
Method Details
-
size
public int size()
Get the number of contained items.
- Specified by:
size
in interface Container<Item>
- Returns:
- the size
-
contains
public boolean contains(Item item)
Check if the given item is equal to any of those contained.
- Specified by:
contains
in interface Container<Item>
- Parameters:
item
- the item to check for membership
- Returns:
- whether such an item is contained