본문으로 바로가기

이전까지 했던 책의 예제들 업로드합니다. 

감사합니다.

package loopexample;

public class ContinueExample {

	public static void main(String[] args) {
		int total = 0;
		int num;
		
		for(num = 1; num <= 100; num++) {
			if(num % 2 == 0)
				continue;
			total += num;
		}
		System.out.println("1부터 100까지의 홀수의 합은: "+total + "입니다.");

	}

}