title: How exactly node == null checks if the stack is full?
body: <p>If the new node we created is null (nothing), how is it not referring to the stack as empty but instead checks if the stack is full?</p>
  <pre><code> //push() function
  
  public void push(int x) {
      
      //create a new node and allocate memory
      Node node = new Node();
  
      //check if the stack is full i.e check for stack overflow
      if(node == null) {
          System.out.println(&quot;\n Stack is full. Stack Overflow!&quot;);
          return;
      }
      node.data = x;
      node.next = head;
      head = node;
  }
  
  //check for an empty stack
  public boolean isEmpty() { 
      return head == null;
  }
  </code></pre>