Scanner 

Scanner를 사용하기 위해서는 import 를 통해서 외부 클래스를 호출

import java.util.Scanner;


다음은 Scanner 객체 생성을 해주어야 하는데

Scanner sc = new Scanner(System.in);//System.in 키보드 입력을 의미함

String name;

int Math;


name= sc.next();

Math= sc.nextInt();


이런식으로 값을 입력 받는다.


next(): 공백 이전까지의 문자열 입력받음

next + 자료형() : nextInt(), nextDouble()

nextLine(): 문자열 전체 입력 

sc.next().charAt(0);: 문자 하나 입력 받는 방법.

+ Recent posts