Control/Lopping Statement : For loop and While loop

Published: (February 5, 2026 at 04:29 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

What are loops?

Loops are used to repeat a block of code.
Instead of writing the same statements many times (e.g., printing a message 100 times), a loop can execute the code repeatedly until a specified condition is met.


While Loop

A while loop evaluates the expression inside the parentheses () before each iteration.

  1. If the expression evaluates to true, the code inside the loop is executed.
  2. After the body runs, the expression is evaluated again.
  3. This process continues until the expression evaluates to false, at which point the loop stops.

Example

int i = 1;
while (i = 'a' && ch = 'a' && ch <= 'z') {
    System.out.println("Good! you have entered a vowel");
    continueLoop = false;
} else {
    System.out.println("Entered Character is not vowel");
}
}
sc.close();
}
}
Back to Blog

Related posts

Read more »

제어 함수

조건문 Conditional Statement 조건에 따라 특정 동작을 하도록 하는 프로그래밍 명령어 명제 - 참 또는 거짓을 객관적이고 명확하게 판별할 수 있는 문장이나 식 관계 연산자 - x == y - x != y 논리 연산자 - X and Y - X or Y - not X IF...

파이썬 기초 (2)

자료형Data Type 1. 논리형bool: True1, False0 2. 정수형int: 1, 2, 3, … 3. 실수형float: 1.4, 5.33 4. 문자열str: 'hello', '안녕하세요' 그 외에도 다양 변수의 메모리 공간을 확보하는 행위가 실행 시점에 발생 변수에 값을...

My Learning Notes

I’ve been programming for 11 years. Mostly web but I touch backend, mobile, devops, AI and almost everything else you can imagine ; I still often feel like I kn...