Function in Java to check if any arguments are null [duplicate]

This question already has an answer here:

How to check multiple objects for nullity?

5 answers

Is there a function in Java to check if any of the arguments are null? If not, is there a reason there isn't? It'd just be syntactic sugar, but it'd be better than stringing a bunch of arg1 == null || arg2 == null || ... statements together.

Something like this:

public static boolean anyNull(Object... obj) {



You could call like this:

anyNull(arg1, arg2, arg3);...

Read More »

By: StackOverFlow - Friday, 13 April

Related Posts