일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- https://goodgid.github.io/HTTP-Communicate-Process/
- https://subicura.com/2017/01/19/docker-guide-for-beginners-1.html
- https://joshua1988.github.io/web-development/javascript/js-async-await/
- https://jcon.tistory.com/189
- https://aws.amazon.com/ko/docker/
- https://siyoon210.tistory.com/130
- https://joshua1988.github.io/web-development/javascript/promise-for-beginners/
- https://sewonzzang.tistory.com/22
- https://appmaster.io/ko/blog/rest-apiran-mueosimyeo-dareun-yuhyeonggwa-eoddeohge-dareungayo
- https://hi-zini.tistory.com/entry/%EB%B9%84%EB%8F%99%EA%B8%B0%EC%A0%81-%EB%B0%A9%EC%8B%9D-%EC%B2%98%EB%A6%AC-%EB%B0%A9%EB%B2%95-Callback-Promise-async-await
- Today
- Total
“Connecting the dots”
JAVASTUDY 10진수를 2진수로 변환하여 출력하는 기능 본문
위 코드는 10진수를 2진수로 변환하여 출력하는 기능을 구현했습니다. 추가로, 2진수 비트를 출력할 때마다 0.5초 간격을 두어 출력 속도를 조절할 수 있도록 Thread.sleep() 메소드를 추가했습니다
위 코드는 10진수를 2진수로 변환하여 출력하는 기능을 구현, 추가로 2진수 비트를 출력할 떄마다 0.5초 간격을 두어 출력 속도를 조절할 수 있도록 Thread.sleep()메소드를 추가 했습니다
메인 함수에서는 SCanner 클래스를 사용하여 사용자로부터 입력값을받지않고,고정된 숫자 10을변수n에 저장합니다
toBinaryString 함수는 입력받은 n을 32비트의 2진수로 변환하여 출력합니다 이를 위해 31부터0까지 반복문을돌면서,n을 i번비트만큼 오른쪽으로 이동시키고(>>) 그결과에서 1의 위치를 추출하기위해 1과 &연산을 수행
출력시간을 확인하기위해 Thread.sleep함수 를 사용하여 0.5초 동안 대기 합니다
마지막으로 출력 결과를 대괄호로 감싸고 줄바꿈하여 2진수 형태로 출력 하는 기능입니다
package exif;
import java.util.Scanner;
public class _02_Exfor2_2진수출력 {
static void toBinaryString(int n) {
System.out.print("[");
for(int i =31; i>=0;i--) {
System.out.print(n>>i&1);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("]");
}
public static void main(String[]args) {
Scanner scanner = new Scanner(System.in);
int n =10;
toBinaryString(n);
}
}
'JAVA' 카테고리의 다른 글
Java Study 파일을 읽어와서 내용을 콘솔에 출력하는 코드 (0) | 2023.04.06 |
---|---|
JAVA STUDY 제어문 (0) | 2023.04.05 |
java if문 (0) | 2023.04.04 |
JAVA STUDY 제어문 (0) | 2023.04.04 |
JAVAStudy (0) | 2023.04.03 |