Commons Lang、BitField#set()
import org.apache.commons.lang.BitField; public class C2009042900 { public static void main(String[] args) { BitField bf; bf = new BitField(5); System.out.println(bf.set(1) + " " + bf.getValue(15)); bf = new BitField(5); System.out.println(bf.set(2) + " " + bf.getValue(15)); bf = new BitField(5); System.out.println(bf.set(15) + " " + bf.getValue(15)); } }
で、
5 5 7 5 15 5