http://www.javatpoint.com |
조건문
if , else if , else
if(boolean_expression){
//실행문;
}else if(boolean_expression){
//실행문;
}else{
//실행문;
}
|
switch
ex)
int grade = 1;
switch(grade){
case 1: 실행구문;
break;
case 2: 실행구문;
default: 실행구문;
}
|
반복문
for : 일정조건동안 반복수행
초기화 ; 조건검사; 증감++
for(int i = 0; i < 5; i++){
실행구문;
}
|
while & do while
public class TestWhile {
public static void main(String[] args) {
int count = 0;
while (count < 10) {
System.out.println(count++);
}
System.out.println("*************");
// do while : 반드시 한번은 실행한다
int point = 0;
do {
System.out.println("do while:" + point);
} while (point > 0);
}
}
|