Contents
결과 + 기호는 더하기에 의미 말고 나열하는 의미도 있다. 
Int(1) + String(”2”) = 12 // 나열의 의미
Int(1) + Int(2) = 3  // 더하기의 의미 
import java.util.Scanner;
public class Add2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); // 키보드 입력 준비
        // 변수의 선언하면 null 값이 들어감.
        // int를 선언하면 0이 들어감.
        int x;
        int y;
        int sum;
        System.out.println("첫 번째 숫자 입력 : ");
        x = sc.nextInt();
        System.out.println("두 번째 숫자 입력 : ");
        y = sc.nextInt();
        sum = x + y;
        System.out.println("합계 : " + sum);
    }
}결과

Share article