https://www.acmicpc.net/problem/11945
백준 11945 - 뜨거운 붕어빵
- hasNext() 메서드
boolean 타입.
다음에 읽어올 요소가 있으면 true, 없으면 false 리턴.
for문 돌면서 입력 받을 n이 있으면 true로 while문 반복,
for문의 n이 종료되면 false로 while문 종료
StringBuilder
reverse()
package algo;
import java.util.Scanner;
public class BJ4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
for (int i = 0; i < n; i++){
while (sc.hasNext()){
StringBuilder sb = new StringBuilder(sc.next());
System.out.println(sb.reverse().toString());
}
}
sc.close();
}
}