public void print() {

    StackNode<T> currentNode = topNode;

    while (currentNode != null) {

      System.out.println(currentNode.getValue());
      currentNode = currentNode.getLastNode();
    }
  }
  public int findHeight() {

    int height = 0;

    StackNode<T> currentNode = topNode;

    while (currentNode != null) {

      height++;
      currentNode = currentNode.getLastNode();
    }

    return height;
  }
  public T pop() {

    if (topNode != null) {

      StackNode newTopNode = topNode.getLastNode();
      T topNodeValue = topNode.getValue();

      newTopNode.setNextNode(null);
      topNode.setLastNode(null);

      topNode = newTopNode;

      return topNodeValue;
    }

    return null;
  }
  public T findMax() {

    StackNode<T> currentNode = topNode;
    T max = topNode.getValue();

    while (currentNode != null) {

      T currentValue = currentNode.getValue();

      if (currentValue > max) {
        max = currentValue;
      }

      currentNode = currentNode.getLastNode();
    }

    return max;
  }
  public T findMin(T currentMin, T max) {

    StackNode<T> currentNode = topNode;
    T min = max;

    while (currentNode != null) {

      T currentValue = currentNode.getValue();

      if (currentMin == null) {
        if (currentValue < min) {
          min = currentValue;
        }
      } else {
        if (currentValue < min && currentValue > currentMin) {
          min = currentValue;
        }
      }

      currentNode = currentNode.getLastNode();
    }

    return min;
  }