main은 메모리를 할당할 수 있는 시작점
static은 메소드 영역
Scanner scanner = new Scanner(System.in);
스캐너 객체를 생성하라는 의미
외부로부터 입력된 데이터를 받아오는 기능을 하는 클래스
System.out 은 콘솔창에 찍힘
바로 형변환하지 말고 String은 String으로 받아서 그 값을 체크하고 형변환을 해줘라
System.out.println("a의 값 입력해주세요!");
String tempA = in.nextLine();
int a2 = Integer.perseInt(tempA);
//안전하게 받아서 int형으로 변환
System.out.println("b의 값 입력해주세요!");
String tempB = in.nextLine();
int b2 = Integer.perseInt(tempB);
int result = a + b ;
System.out.printf("a+b = %02d \n", result);
next는 문자열 하나만 취급
While 같은 경우엔 조건식을 주고 시스템을 돌릴 때 while 사용
String c;
while (true) {
c = in.nextLine();
if (c.equals("q")) {
break;
}
System.out.println(c);
}
내가 원하는 값을 빠르게 반복을 돌려(추출기형태의 특정 목적이 있음, 범위를 줌)
but, for안에 while을 넣는 경우는 드물다.
.은 메소드 장착이라고 생각하면 편함