Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 조코딩
- 자바 if문
- react with typescript
- 자바 for문
- 항해99 2기
- java
- 변수
- 정보처리기사실기
- 항해99
- 자바 while문
- 이클립스 DB연동
- 자바 조건문
- 자바
- 자바 반복문
- 타입스크립트
- react ag grid
- 자바 switch문
- 프로그래머스
- 자바 공배수
- 자바 자동캐스팅
- Vue3
- 자바 삼항연산자
- TypeScript
- 자바 public
- 자바 강제 캐스팅
- 자바 스캐너
- MySQL
- 자바 구구단 출력
- 자바 향상된 for문
- Til
Archives
- Today
- Total
뇌 채우기 공간
[자바JAVA] 10진수를 2진수로, 8진수로, 16진수로 출력하기 / Integer.toBinaryString/ Integer.toOctalString/ Integer.toHexString 본문
JAVA/java 실습
[자바JAVA] 10진수를 2진수로, 8진수로, 16진수로 출력하기 / Integer.toBinaryString/ Integer.toOctalString/ Integer.toHexString
자바칩 프라푸치노 2020. 9. 17. 08:14안녕하세요 자바칩프라푸치노입니다.
오늘은 10진수를 2진수로 8진수로 16진수로 출력하는 법을 알아보겠습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package sec01_exam;
public class BitEx {
public static void main(String[] args) {
System.out.println(Integer.toBinaryString(45));
System.out.println(Integer.toBinaryString(25));// 2진수로 출력 하는 것
System.out.println(Integer.toOctalString(45));
System.out.println(Integer.toOctalString(25)); // 8진수로 출력하는 것
System.out.println(Integer.toHexString(45));
System.out.println(Integer.toHexString(25)); // 16진수로 출력하는 것
//Integer 포장 클래스를 이용하여 각 진수별로 변환하고 있다.
}
}
|
cs |
여기보이시는 것 처럼 요런 메서드를 사용하시면 된답니다!
10진수를 2진수로 변환하는 것은 Integer.toBinaryString
10진수를 8진수로 변환하는 것은 Integer.toOctalString
10진수를 16진수로 변환하는 것은 Integer.toHexString
출력결과입니다.
728x90
'JAVA > java 실습' 카테고리의 다른 글
[자바JAVA] 연산자 - 삼항연산자 (0) | 2020.09.17 |
---|---|
[자바JAVA] 연산자 - 자바 관계 연산자 (0) | 2020.09.17 |
[자바JAVA] 연산자 - 비트연산자 &|^ (0) | 2020.09.16 |
[자바JAVA] 연산자 - 쉬프트연산자 (0) | 2020.09.16 |
[자바JAVA] 연산자 - 논리부정연산자 ! (0) | 2020.09.16 |