public static int nextPowerOf2(int x){
  long i=1;
  while (i < x && i < (Integer.MAX_VALUE / 2)) {
    i+=i;
  }
  return (int)i;
}

public static int nextPowerOf2 ( int x ) { long i = 1 ; while ( i < x && i < ( Integer . MAX_VALUE / 2 ) ) { i += i ; } return ( int ) i ; }
get the value that is equal or higher than this value , and that is a power of two .
