practice
Class Collection

java.lang.Object
  extended by practice.Collection
Direct Known Subclasses:
Stack

public abstract class Collection
extends Object

This abstract class represents a collection. A collection only has a size.


Constructor Summary
Collection()
          Creates an empty collection.
 
Method Summary
 void add()
          Adds an element to this collection.
 boolean equals(Object object)
          Tests if this collection is the same as the given object.
 boolean isEmpty()
          Tests if this collection is empty.
 void remove()
          Removes an element of this collection.
 int size()
          Returns the size of this collection.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Collection

public Collection()
Creates an empty collection. The size of this collection is zero.

Method Detail

size

public int size()
Returns the size of this collection.

Returns:
the size of this collection.

isEmpty

public boolean isEmpty()
Tests if this collection is empty. A collection is empty if its size is zero.

Returns:
true if this collection is empty, false otherwise.

add

public void add()
Adds an element to this collection. The size is incremented by one.


remove

public void remove()
Removes an element of this collection. The size is decremented by one.


equals

public boolean equals(Object object)
Tests if this collection is the same as the given object. Two collections are the same if they have the same size.

Overrides:
equals in class Object
Parameters:
object - An object.
Returns:
true if this collection is the same as the given object, false otherwise.