백준 단계별
[Java] 백준 1000번: A+B
pullwall
2022. 7. 27. 15:02
728x90
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b;
a = sc.nextInt();
b = sc.nextInt();
System.out.println(a+b);
}
}
우선 입력을 받기 위해 Scanner 클래스를 import 해준다.
Scanner sc = new Scanner(System.in);
위와 같이 Scanner 객체를 생성해주고
(System.in 은 키보드를 통해 입력받는 자바의 기본적인 언어라고 한다.)
각 변수에 sc.nextInt(); 를 통하여 입력값을 변수에 저장해주었다.
728x90