- 문제> 1에서 10까지 숫자를 출력하는데, 짝수와 홀수만 출력하기.
- 2, 4, 6, 8, 10 => 숫자 사이의 간격 2, 변환식 i+=2(i = i + 2)
- 1, 3, 5, 7, 9 => 숫자 사이의 간격 2
package com.dream.controls;
public class ForEx03 {
public static void main(String[] args) {
for(int i=1; i<10; i+=2) {
System.out.print("\t"+i); //\t 탭 키와 같은 역할을 한다.
}
System.out.println("\n========================="); //\n 은 줄바꿈을 한다.
for(int i=2; i<=10; i+=2) {
System.out.print("\t"+i);
}
}
}