title: Should I use my own implementation or the stack class in java.util package?
body: <p>In Java, I can implement my own <code>Stack</code> like below or use the already provided <code>java.util.Stack</code> class.</p>
  
  <pre><code>public class stack {
  
  private int maxSize; //max size of stack
  private char[] stackArray;
  private int top; //index poistion of last element
  
  public stack(int size){
      this.maxSize=size;
  
      this.stackArray=new char[maxSize];
      this.top=-1; //    
      }
  
  
  public void push(char j){
  
      if (isFull()) {
          System.out.println("SORRY I CANT PUSH MORE");
      }else{
  
      top++;
      stackArray[top]=j;
          }
      }
  
  public char pop(){
  
      if(isEmpty()){
          System.out.println("Sorry I cant pop more!");
          return '0';
      }else{
  
         int oldTop=top;
         top--;
         return stackArray[oldTop];    
         }
      }
  
  
  public char peek(){
      if(!isEmpty()) {
          return stackArray[top];
          }
      }
  
  
  public boolean isEmpty(){
      return (top==-1);
      }
  
  public boolean isFull(){
      return (maxSize-1 == top);
      }
  
  } //end of stack class
  </code></pre>
  
  <p>The second way is to use the <code>Stack</code> class in Java API.</p>
  
  <pre><code>Stack&lt;String&gt; stacky = new Stack&lt;&gt;();
  </code></pre>
  
  <p>The same is the situation with <code>Queues</code> in Java.</p>
  
  <p>Should I go with my own implementation when using <code>Stacks</code> or <code>Queues</code>?</p>