title: Creating a stack with an array, what am I doing wrong?
body: <p>Pretty simple idea, I am just not sure why it won't work. I am getting an error when I call Stack b = new Stack(5); in main.</p>
  
  <p>Here is main</p>
  
  <pre><code>public class Test {
  
  public static void main(String[] args) {
   Stack b = new Stack(5);
    b.push('a');
    b.push('b');
    b.push('c');
    b.printStack();
  
   }
   }
  </code></pre>
  
  <p>Here is my stack class</p>
  
  <pre><code>public class Stack {
   char[] stack;
   int items;
  
   public Stack(int size) {
   stack = char[size];
   items = 0;
  
   }
  
   public void push (char add){
     if (items == stack.length) {
     System.out.println("Stack is full");
    }
     else {
    stack[items] = add;
    }
   }
  
  
     public void printStack() {
    if (items == 0)
     return;
     else {
     for (int i = 0; i &lt; items; i++)
    System.out.println(i);
    }
    }
     }
  </code></pre>