Commons Lang、BooleanUtils.toInteger()
import org.apache.commons.lang.BooleanUtils; public class C2009032600 { public static void main(String[] args) { System.out.println(BooleanUtils.toInteger(true)); System.out.println(BooleanUtils.toInteger(false)); System.out.println(BooleanUtils.toInteger(true, 10, 20)); System.out.println(BooleanUtils.toInteger(false, 10, 20)); System.out.println(BooleanUtils.toInteger(new Boolean(true), 10, 20)); System.out.println(BooleanUtils.toInteger(new Boolean(false), 10, 20)); } }
で、
1 0 10 20 10 20