하지만 대량의 데이터를 처리할 때는 상대적으로 성능이 떨어질 수 있다.
[import]
import java.util.Scanner;
[선언]
Scanner sc = new Scanner(System.in);
[예제]
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int x;
int y;
int sum;
System.out.print("첫 번째 정수를 입력하시오: ");
x = input.nextInt();
System.out.print("두 번째 정수를 입력하시오: ");
y = input.nextInt();
sum = x + y;
System.out.println("합계: " + sum);
}
}
[결과]
첫 번째 정수를 입력하시오: 17
두 번째 정수를 입력하시오: 25
합계: 42