Class LinkedList

java.lang.Object
  extended by LinkedList

public class LinkedList
extends java.lang.Object


Constructor Summary
LinkedList()
          Creates an empty linked list.
 
Method Summary
 boolean add(int index, java.lang.String newData)
          Adds data to the given index of the linked list.
 boolean delete(int index)
          Deletes data from the given index of the linked list.
 java.lang.String getData(int index)
          Returns the data at the given index.
 void printList()
          Prints all data in the linked list to the screen, in order, one item per line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedList

public LinkedList()
Creates an empty linked list.

Method Detail

add

public boolean add(int index,
                   java.lang.String newData)
Adds data to the given index of the linked list. Returns true if successful, false otherwise.

Parameters:
index - Position at which to add the new data: 0 = head
newData - Data to add to the linked list

delete

public boolean delete(int index)
Deletes data from the given index of the linked list. Returns true if successful, false otherwise.

Returns:
True if delete is successful, false otherwise.

getData

public java.lang.String getData(int index)
Returns the data at the given index. Returns "null" if there is no data at that index.

Parameters:
index - Index of data to return
Returns:
Data at the given index (or null if it does not exist)

printList

public void printList()
Prints all data in the linked list to the screen, in order, one item per line.