package com.study.javastudy.study;

public class ForExam {
    public static void main(String[] args) {
        int total = 0;
//       for (int i = 1; i <= 100; i++) {
//           if(i % 2 != 0) { // 홀수일 때
//               continue; // 아래식을 계속 수행하라
//           }
//           total = total + i;
//       }
//        System.out.println(total); // 2550

       for (int i = 1; i <= 100; i++) {
           total = total + i;
           if(i == 50) { // i가 50일 때
               break; // 멈춰라
           }
       }
        System.out.println(total); // 1275
    }
}

'자바 기초' 카테고리의 다른 글

배열 사용하기  (0) 2024.01.27
배열 만들기  (0) 2024.01.27
do while문  (0) 2024.01.26
while 반복문  (0) 2024.01.26
switch 조건문  (0) 2024.01.26

+ Recent posts