import java.io.*;
class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
String[] input = br.readLine().split(",");
int a = Integer.parseInt(input[0]);
int b = Integer.parseInt(input[1]);
sb.append(Integer.toString(a + b)).append("\n");
}
System.out.print(sb);
}
}
불필요한 Integer.toString()
sb.append(Integer.toString(a + b)) // 불필요
sb.append(a + b) // 자동 변환됨
public class 권장
class Main // 동작하지만 비권장
public class Main // 백준 표준
import java.io.*;
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());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
String[] input = br.readLine().split(",");
int a = Integer.parseInt(input[0]);
int b = Integer.parseInt(input[1]);
sb.append(a + b).append("\n");
}
System.out.print(sb);
}
}
개선: Integer.toString() 제거, public class 사용
백준 입출력 최적화:
split(",")로 쉼표 구분 입력 처리#백준 #입출력 #BufferedReader #StringBuilder #Bronze3