Here you can find the source of nextPowerOfTwo(int num)
public static int nextPowerOfTwo(int num)
//package com.java2s; public class Main { public static int nextPowerOfTwo(int num) { int result = 1; while (num != 0) { num >>= 1;// w ww.ja v a2 s .c om result <<= 1; } return result; } }