티스토리 뷰
1. for문을 활용해서 1부터 100까지 차례대로 출력하기
public class Main {
public static void main(String args[]) {
for (int i=0; i<100; ++i) {
System.out.println(i+1);
}
}
}
2. while문을 활용하여 1부터 100까지 차례대로 출력하기
public class Main {
public static void main(String args[]) {
int num = 1;
while (num <= 100) {
System.out.println(num);
num++;
}
}
}
'JAVA' 카테고리의 다른 글
| 2단부터 9단까지 구구단 출력 (이중 for 문) (0) | 2023.09.18 |
|---|---|
| 구구단 n단 출력하기(for문) (0) | 2023.09.18 |
| 여러가지 값 입력받기 (0) | 2023.09.10 |
| N줄 연속으로 출력하기 (0) | 2023.09.10 |
| hello world 출력하기 (0) | 2023.09.10 |