1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    //입력
        
        Scanner sc = new Scanner(System.in); // jdk5 추가됨
        int num = sc.nextInt();
        
        //빠르다
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine(); // 문자열로만 리턴됨, 사용자가 입력한 한 줄을 통째로 문자열로 받아옴.
        s="20";
        int num = Integer.parseInt(s); //숫자로 변경
        //int num = Integer.valueOf(s); //내부적으로  parseInt를 다시 호출.
        s="1 2 3 4 5";
        String[] srr = s.split(" ");
        
        
        
        //출력
        System.out.println(); //느리다. 한번에 묶어서 출력하는 것이 좋다.
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        bw.write("abcdefg\n"); //줄 안바꿔줌, \n
cs


'Computer Science > Languages' 카테고리의 다른 글

[java] 쓰레드(Thread)  (0) 2019.01.24
[java] 예외처리  (2) 2019.01.24
[java] Collection 활용  (0) 2019.01.17
[java] interface  (0) 2019.01.16
[Java] final, static  (0) 2019.01.16

+ Recent posts