Class NameList

java.lang.Object
  |
  +--NameList

public class NameList
extends java.lang.Object

This class is a simple example of creating, initializing, and using an ArrayList. It is based on the same class that was implemented with regular arrays in the ex15 examples.


Constructor Summary
NameList(int count)
          The NameList class manages an ArrayList of names.
 
Method Summary
 void addName()
          Add another name to the list at random
 java.lang.String getName(int idx)
          retrieve the name at a particular index
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NameList

public NameList(int count)
The NameList class manages an ArrayList of names.

Parameters:
count - initial number of strings in the ArrayList
Method Detail

getName

public java.lang.String getName(int idx)
retrieve the name at a particular index

Parameters:
idx - the index of the desired name
Returns:
The name at that index, or "Unknown" if idx is out of range

addName

public void addName()
Add another name to the list at random