Checks if all items are negative This piece of code checks to see if all the values within an array are all negative and returns true if they all are.

public static boolean allNegatives(int[] a) {

  if(a == null) {

      return false;

   }

    for(int i = 0; i &lt; a.length; i++) {
        if(a[i] &gt; 0)
            return false;
    } return true;
}
With java 8 you can reduce your code using a more functional programming. It would be something like next. You could even reduce it to one line: 

public static boolean allNegatives(int[] a) {
     //@bowmore suggestion edit
     return a != null &amp;&amp; Arrays.stream(a).allMatch(i -&gt; i &lt; 0);
}