Here you can find the source of nextPowerOfTwo(int value)
public static int nextPowerOfTwo(int value)
//package com.java2s; public class Main { /**//w ww . jav a 2 s . c o m * Returns the smallest power-of-two that is greater than or equal to the supplied (positive) * value. */ public static int nextPowerOfTwo(int value) { return (Integer.bitCount(value) > 1) ? (Integer.highestOneBit(value) << 1) : value; } }