Integer.bitCount() 메서드
·
Stack/Java
int a = Integer.bitCount(n); int compare = n+1; while(true) { if(Integer.bitCount(compare)==a) break; compare++; } return compare; Integer.bitCount() 메서드는 파라미터에 int 형 정수가 들어갔을때 정수의 이진수 ex) 13=1101 에서 1의 개수인 3을 리턴하게된다 위의 코드는 a보다 큰 상수 compare 중에서 a의 이진수와 1의 개수가같은 가장작은 compare 정수를 리턴하는 매서드이다