Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: Collection
|
Posted: Apr 8, 2003 11:44 AM
|
|
In Java, implementing Collection specifically means implementing the interface called Collection (java.util.Collection). You can look it up in the API documentation. Even better, if you have a smart editor (or IDE), it will automatically flesh out the implementation of any interface you implement. To "implement" an interface, you add "implements [interface mame]" after your class declaration, then add all the methods to your class which the interface contains.
Here's what it will look like:
class MyZanyCollection implements Collection
{
public Collection()
{
}
public boolean Add( object o )
{
// Add the one object to this collection.
}
public void AddAll( Collection c )
{
// Iterate over the Collection c and add each item
// to this Collection.
}
... all the rest of the methods in Collection ...
}
|
|