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