import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner; // module -> 누군가가 미리 개발해둔 기능

// 입력 처리
public class sample2 {
    public static void main(String[] args) throws IOException {
    	// BufferedReader 사용하고 싶다면, throws IOException 추가
        // 입력
        Scanner sc = new Scanner(System.in);

        // boolean
            // sc.nextBoolean();

/*        boolean b;
        System.out.print("boolean = ");
        b = sc.nextBoolean();
        System.out.println("b = " + b);*/

        // int
            // sc.nextInt();
        // double
            // sc.nextDouble();
        // String
            // 띄어쓰기 이후의 입력이 무시됨
        String name;
        System.out.print("이름 = ");
        name = sc.next();
        System.out.println(name + "님 반갑습니다.");

        // 띄어쓰기 가능한 입력 Buffer (저장공간)
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        // 엔터키를 누르기 전까지 모든 입력이 저장된다.
        String address;
        System.out.print("주소 = ");
        address = br.readLine();
        System.out.println("주소: " + address);

    }
}

+ Recent posts