import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.<i>in</i>);
while (true) {
String line = scanner.nextLine();
System.<i>out</i>.println(line);
}
}
}
이 문제 같은 경우 종료 조건이 없어서 while에 true 를 사용하는 것과 hasNextLine()둘 다 결과에 차이가 전혀 없는데 왜 true는 틀린 답이 되는걸까요?
sos99661 2년 전
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.<i>in</i>); while (true) { String line = scanner.nextLine(); System.<i>out</i>.println(line); } } } 이 문제 같은 경우 종료 조건이 없어서 while에 true 를 사용하는 것과 hasNextLine()둘 다 결과에 차이가 전혀 없는데 왜 true는 틀린 답이 되는걸까요?