# Scanner

What is Scanner?

Scanner는 화면으로부터 데이터를 입력받는 기능을 제공하는 클래스이다.

How to use Scanner?

1. import 문 추가 : 해당 클래스가 어떤 패키지에 속해있는지에 대한 정보
2. Scanner 객체 생성

```java
Scanner scanner = new Scanner(System.in);
```

3\. Scanner 객체 사용 : **scanner.*****nextInt*****()**

```java
int num = scanner.nextInt();//화면에서 입력받은 정수를 num에 저장.
float num = scanner.nextFloat();//실수 입력받는다.
String input = scanner.nextLine();//행 단위로 입력받는다.
int num = Integer.parseInt(input);//문자열(input)을 숫자로 변환한다.
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/java/ch2/scanner.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
