JAVA/Escape + Output + Input
[JAVA - Eclipse] Input
삐옥
2021. 11. 14. 13:13

Input
콘솔 출력
1. print()
2. println()
3. printf()
콘솔 입력
System.in.read()
- 사용자가 입력한 문자를 읽어오는 기능
- 읽어온 문자를 숫자(문자 코드값)로 돌려준다.
- 영어와 숫자, 특수문자(ASCII)만 입력가능. 1바이트 입력만 가능
- 한글 불가능(2바이트)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
System.out.print("입력: ");
int data = System.in.read(); //버퍼안의 1문자를 가져와라
System.out.println(data); //65
data = System.in.read(); //버퍼
System.out.println(data); //13
data = System.in.read(); //버퍼
System.out.println(data); //10
data = System.in.read(); //버퍼
System.out.println(data);
data = System.in.read();
System.out.println(data);
data = System.in.read();
System.out.println("종료");
|
cs |