본문 바로가기

Programming/Java

[Java] 키 입력(Scanner)

반응형
import java.util.Scanner;


Scanner sc = new Scanner(System.in);
int n = sc.nextInt();

sc.close();

 

 

참고: https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html

 

Scanner (Java Platform SE 8 )

Scans the next token of the input as a float. This method will throw InputMismatchException if the next token cannot be translated into a valid float value as described below. If the translation is successful, the scanner advances past the input that match

docs.oracle.com

 

반응형