#십진수를 이진수로 | Binary | Bit ## CODE <a class="btn btn-default" href="/codes/1420">Link</a> ``` public class Main { public static void main(String[] args) { // input int n = Integer.parseInt(args[0]); // convert String a = Integer.toString(n, 2); // print System.out.println("X => " + a); } } ``` ## INPUT ``` 1 ``` ## OUPUT ``` X => 1 ``` (질문!!) String a = Integer.toString(n, 2); 여기서 toString은 메서드로 봐야하나요 멤버변수(필드)로 봐야하나요?? 메서드로 본다면 toString(int i, int radix) Returns a string representation of the first argument in the radix specified by the second argument. 첫번째 매개변수에 정수 값이 들어갸야하는데 n을 input에서 숫자로 변환해서 넣고 두번째 매개변수에서는 2진수로 바꾸겠다?? 요것인거 같고 만약 멤버변수로 본다면 호출할 멤버변수가 없는데.. 뭘보 보는게 맞나요??
Q. 여기서 toString은 메서드로 봐야하나요 멤버변수(필드)로 봐야하나요?? => 메소드로 보셔요. toString(int i, int radix) ``` Returns a string representation of the first argument in the radix specified by the second argument. ``` 첫번째 매개변수에 정수 값이 들어갸야하는데 n을 input에서 숫자로 변환해서 넣고 두번째 매개변수에서는 2진수로 바꾸겠다?? => 맞습니다.