I want to determine if an array subrange contains a null reference. Anyway:
public static <T> boolean containsNull
(T[] array, int fromInclusive, int toExclusive)
{
for (int i = fromInclusive; i < toExclusive; ++i)
{
if (array[i] == null) return true;
}
return false;
}
Is there such a way in the Java library, so I don't need to manually iterate over the array? Perhaps I was spoiled by C ++ with excellent support for algorithmically focused code, where I can simply write:
#include <algorithm>
bool found_null = (std::find(array + from, array + to, 0) != array + to);
source
share