public static <T>T[] requireNonNullElements(T[] array){
  requireNonNull(array,"The provided array is null.");
  int len=array.length;
  for (int i=0; i < len; i++) {
    if (array[i] == null) {
      throw new NullPointerException("Item " + i + " in the array "+ Arrays.toString(array)+ " is null");
    }
  }
  return array;
}

public static < T > T [ ] requireNonNullElements ( T [ ] array ) { requireNonNull ( array , "The provided array is null." ) ; int len = array . length ; for ( int i = 0 ; i < len ; i ++ ) { if ( array [ i ] == null ) { throw new NullPointerException ( "Item " + i + " in the array " + Arrays . toString ( array ) + " is null" ) ; } } return array ; }
checks if this array is non null and also that all members are non - null . if a null is detected a nullpointerexception is thrown .
