Programming Resources
For Fun and Learning
Charles Cusack
Computer Science
Hope College
main

Python
C++

JAVA


PHP
SQL
Alice

StackExample


Description

ArrayListStack.java
ArrayReverseIterator.java
ArrayStack.java
LinkedStack.java
Node.java
NodeIterator.java
StackInterface.java
TestStack.java

Node.java

/**
 * A simple Node class for use in a linked list type structure
 * 
 * @author Chuck Cusack
 * @version 1.0, February 2008
 */
public class Node<T>
{
    // This is one example where 
    private Node<T> next;
    private T key;
 
    public Node()
    {
        key=null;
        next=null;
    }
    
    public Node(T key) {
        this.key=key;
        next=null;
    }
    
    public Node(T key,Node<T> next) {
        this.key=key;
        this.next=next;
    }
    
    public Node<T> getNext() {
        return next;
    }
    
    public void setNext(Node<T> next) {
        this.next=next;
    }    
    
    public boolean hasNext() {
        return next!=null;
    }
    
    public void setKey(T key) {
        this.key=key;
    }
    
    public T getKey() {
        return key;
    }
}