/*
* Scanner 클래스
* 예외처리를 명시하지 않아도 가능
*/
package com.test0520;
import java.util.Scanner;
public class Test2 {
public static void main(String[] args) {
String name;
int kor, eng;
Scanner sc = new Scanner(System.in);
/*
System.out.println("이름 ? ");
name = sc.next();
System.out.println("국어? ");
kor = sc.nextInt();
System.out.println("영어? ");
eng = sc.nextInt();
*/
/* //스캐너 기본 공백구분
System.out.print("이름 국어 영어 [ 입력 공백으로 구분]");
name = sc.next();
kor = sc.nextInt();
eng = sc.nextInt();
*/
System.out.print("이름 국어 영어 [, 로구분]");
sc = new Scanner(sc.next()).useDelimiter("\\s*,\\s*"); // "\\s*" 0글자이상
name = sc.next();
kor = sc.nextInt();
eng = sc.nextInt();
System.out.println(name+":"+ kor + ":" + eng);
}
}
반응형
'JAVA' 카테고리의 다른 글
[JAVA] 연산자 (0) | 2021.12.21 |
---|---|
[Java/Jsp] 문자.split 에서 "." 이걸로 안 잘리는 경우 (0) | 2021.12.20 |
[JAVA] DATE 클래스 살아온날수 (0) | 2021.12.19 |
[JAVA] Calendar 클래스 주간 (0) | 2021.12.19 |
[JAVA] Calendar 클래스 달력 (0) | 2021.12.19 |
최근댓글