⚠ 리턴 값이 String
임
⚠ IO Exception
예외처리해주어야 함.
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int answer = 0;
for(int i = 1; i < n+1; i++) {
answer += i;
}
System.out.print(answer);
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine()); // br.readLine()은 리턴 값이 String
int answer = 0;
for(int i = 1; i < n+1; i++) {
answer += i;
}
System.out.print(answer);
br.close();
}
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int T = Integer.parseInt(br.readLine()); // 2 5
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
bw.write(Integer.parseInt(st.nextToken()); // 2
bw.write(Integer.parseInt(st.nextToken()); // 5
br.close(); bw.flush(); bw.close();
}
String
임IO Exception
처리해주어야 함. public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int answer = 0;
for(int i = 1; i < n+1; i++) {
answer += i;
}
System.out.print(answer);
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine()); // br.readLine()은 리턴 값이 String
int answer = 0;
for(int i = 1; i < n+1; i++) {
answer += i;
}
System.out.print(answer);
br.close();
}