Here you can find the source of nextPowerOf2(int x)
public static int nextPowerOf2(int x)
//package com.java2s; //License from project: Open Source License public class Main { public static int nextPowerOf2(int x) { return 1 << (x == 0 ? 0 : 32 - Integer.numberOfLeadingZeros(x - 1)); }//from w w w . j a va 2 s .c o m }