title: Returning even numbers from a stack?
body: <p>How do I pass a stack of integers, which returns the number of even numbers. The stack must remain unchanged after the method finishes execution. And Return null if the stack is empty.</p>
  
  <p>This is what i got so far, sorry i am a beginner.</p>
  
  <pre><code>public static int countEven(Stack&lt;Integer&gt; stk) {
  
          Stack stack = new stack();
          int count = 0;
  
          while (int i=0; i&lt;stack.length; i++);        
              int value = s.pop();
  
              if (stack %2 == 0);                       
                  count++;
  
              stack.push(value);
  
          while (int i=0; stack != 0; i++);
              s.push(stack.pop());
  
      return 0;
  }
  </code></pre>