Stack/Java2 Integer.bitCount() 메서드 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 정수를 리턴하는 매서드이다 2023. 1. 5. 자바기초문법 자바는 camel case 즉 대문자를 중간에 넣어서 구분 Ex) 파이썬 final_numb 자바 finalNumber 변수 선언중에 final int 이중 final 은 접근제어자 이다 변수의 변동이되지않는다 변수의 이름의 첫글자는 숫자 , 특수문자는 안쓰는게 국룰이다 2022. 5. 4. 이전 1 다음