WebDev/본과정
반복문 심화 및 메소드 기초
1. 반복문 3가지의 무한루프 만드는 방법은? 1-1. for문 public class Main { public static void main(String[] args) { for (; ;) { // 초기 조건, 종료 조건, 증감 조건이 명확하지 않을시에 무한루프가 발생한다. ... } } 1-2. while문 public class Main { public static void main(String[] args) { while (true) { ... // break 키워드가 별도로 없을시에 무한루프가 발생한다. } } 1-3. while문 public class Main { public static void main(String[] args) { int num = 0; while (true) { if ..
2021. 4. 30. 18:05
최근댓글