title: Method filter even value in array and return them in a new array
body: <p>Could any one tell me how to correct following code to work correctly?</p>
  
  <p>Write a method filterEvens which takes in an array of integers and returns a new array containing only the even values.</p>
  
  <p>new array containing only the even values. Eg:</p>
  
  <pre><code>int[] data = {1, 3, 4, 2, 0, 5, -2};
  int[] evens = filterEvens(data);
  
  public static int[] filterEvent(int[] data) {
      int countLength = 0;
  
      for (int i = 0; i &lt; data.length; i++) {
          if (data[i] % 2 == 0) {
              countLength++; 
          }
      }
  
      int[] filArray = new int[countLength]; 
      for (int i = 0; i &lt; data.length; i++) {
          if (data[i] % 2 == 0) {
              filArray[i] = data[i]; 
          }
      }
  
      return filArray;  
  }
  </code></pre>