Commons Lang、BooleanUtils.toBooleanDefaultIfNull()
import org.apache.commons.lang.BooleanUtils; public class C2009032400 { public static void main(String[] args) { System.out.println(BooleanUtils.toBooleanDefaultIfNull(true, true)); System.out.println(BooleanUtils.toBooleanDefaultIfNull(false, true)); System.out.println(BooleanUtils.toBooleanDefaultIfNull(null, true)); System.out.println(BooleanUtils.toBooleanDefaultIfNull(null, false)); } }
で、
true false true false