Here you can find the source of nextPowerOfTwo(int value)
public static int nextPowerOfTwo(int value)
//package com.java2s; //License from project: Apache License public class Main { public static int nextPowerOfTwo(int value) { return 1 << (32 - Integer.numberOfLeadingZeros(value - 1)); }/* w w w . j a v a2 s . co m*/ }