Archives for May 8th, 2009
Varargs Null Checking
Friday, May 8th, 2009
VarArgs Null checking? This should be easy, right? All we need to do is put a “VarArgs”.length == 0 check before the important method’s body and we are set (See Checker class), correct?
class Checker {
public void check(Arg… args){
if(args.length == 0) return;
final List<Arg> someArgs = Arrays.asList(args);
for(Arg each: someArgs){
System.out.println("checked:" + each.toString());
}
}
}
class Arg{
private final String [...]