title: Getting java.lang.NullPointerException while returning an array of integers in java
body: <pre><code>public class Omit {
  
      int[] omitnum(int[] a) {
          int[] arr = null;
          for (int i = 0; i &lt;= 7; i++) {
              if (a[i] &gt;= 13 &amp;&amp; a[i] &lt;= 19) {
                  System.out.print(a[i]);
              } else {
                  arr[i] = a[i];
              }
          }
          return arr;
      }
      public static void main(String[] args) {
          Omit c = new Omit();
          int[] a = {
              1,
              2,
              3,
              12,
              113,
              14,
              19,
              20
          };
          int[] b = null;
          b = c.omitnum(a);
          for (int i = 0; i &lt;= 7; i++) {
              System.out.println(b[i]);
          }
      }
  
  }
  
  }
  </code></pre>
  <p>Getting this error while running Exception in thread &quot;main&quot;</p>
  <pre><code>java.lang.NullPointerException
      at omit.Omit.omitnum(Omit.java:20)
      at omit.Omit.main(Omit.java:28)
  </code></pre>
  <p>Initialized an array to return some values but it isn't returning any values and giving null error</p>