-1
public class whatever {
public static void main(String[] arguments){
int points = 0;
int target = 100;
tagetLoop:
while (target <= 100) {
for (int i = 0; i < target; i++) {
if (points > 50)
break tagetLoop;
points = points + i;
System.out.println("Points: " + points);
}
}
}
}
내가 실행할 때마다 최종 출력은 "Points : 55"가됩니다. 왜 55가 아니라 50입니까? points
의루프 내에서 루프가 발생하는 이유는 무엇입니까?
(점> = 50) – jospratik
무엇이 디버거인지 아십니까? – 1ac0
스택 오버플로에 오신 것을 환영합니다! 디버깅은 모든 프로그래머에게 중요한 기술입니다. IDE 내장 디버거를 사용하는 방법을 배우는 것이 좋습니다. 또한 System.out.println() 문을 코드에 추가하여 어떤 일이 일어나고 있는지 확인할 수 있습니다. –