Java Reference
In-Depth Information
package org.oreilly.javaGoodParts.examples.statistics;
import java.util.List;
/**
* The <code>Team</code> interface, which defines
* the notion of a team for our statistics package. A
* team is, at first incarnation, simply a collection of
* players. All teams have a name.
*/
public interface Team {
/**
* Return a <code>String</code> that is the name of
* this team.
*/
String getName();
/**
* Return a list of the players that are on this
* team.
*/
List getPlayerList();
/**
* Add a player to the team.
*/
void addPlayer(Player toAdd);
/**
* Remove a player from the team.
*/
void removePlayer(Player toRemove);
}
We see that one of the methods in the interface, getPlayerList() , returns a List object. This
is a type that is defined in the java.util package, and as the name implies, it provides us a
higher-level construct that is made up of other objects. As of Java 1.5, we would declare this
somewhat differently, but we are going to start simple, and get more complex a bit later in this
chapter.
The java.util package is itself a rather strange beast. The package name util is about
as uninformative as you can get; it could just as easily have been called stuff or other
or doesNotFitAnywhereElse . Indeed, this package contains a motley group of interfaces,
classes, and exceptions for such things as the system random number generator, a string token-
Search WWH ::




Custom Search