Here you can find the source of nextPowerOfTwo(int value)
public static int nextPowerOfTwo(int value)
//package com.java2s; //License from project: Open Source License public class Main { public static int nextPowerOfTwo(int value) { if (value == 0) return 1; if ((value & value - 1) == 0) return value; value |= value >> 1;/* w ww .j av a2 s . com*/ value |= value >> 2; value |= value >> 4; value |= value >> 8; value |= value >> 16; return value + 1; } }