import java.util.Random; public class ManyChoicesB { public static void main(String[] args) { Random random = new Random(); final int NUMBER_OF_BITS = 32; String bits = ""; for (int i = 0; i < NUMBER_OF_BITS; i++) { if (random.nextBoolean()) { bits += "0"; } else { bits += "1"; } } System.out.println(Integer.parseUnsignedInt(bits, 2)); } }