happy coding

[java] 10951.a+b-4 본문

coding study/baekjoon

[java] 10951.a+b-4

yeoonii 2023. 4. 5. 21:20

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        //int n = Integer.parseInt(br.readLine());
        String input;

        while ((input = br.readLine()) != null) {
            StringTokenizer st = new StringTokenizer(input);

            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());

            System.out.println(a + b);
        }
    }
}

file:///var/folders/l3/mlb0x9_536x4w0pq6rrhrg3m0000gn/T/TemporaryItems/NSIRD_screencaptureui_BHeg3m/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202023-04-05%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%209.21.08.png

input = br.readLine() != null

 

>> input값이 null이 아닌경우 반복문을 실행하고, null인 경우 종료한다.

'coding study > baekjoon' 카테고리의 다른 글

[java] 10807.개수 세기  (0) 2023.04.10
[java] 10871.배열  (0) 2023.04.08
[java] 10952.a+b-5  (0) 2023.04.05
[java] 8393.합구하기  (0) 2023.04.04
[java] 10950.a+b-3  (0) 2023.04.04
Comments