public static void main(String args[]){
int cnt = 0;
while(cnt < 10){
System.out.println(cnt);
cnt++;
}
System.out.println("끝!");
}
결과
0
1
2
3
4
5
6
7
8
9
끝!
public static void main(String[] args) {
int cnt = 0;
//do 블럭을 한 번 실행하고 나서 조건를 체크함
do{
System.out.println(cnt);
cnt++;
}while(cnt < 10);
System.out.println("끝!");
}
결과
0
1
2
3
4
5
6
7
8
9
끝!
//배열의 선언, 생성
int[] it = new int[6];
//배열의 선언, 생성(명시적 배열 생성)ㅣ, 초기화
char[] ch2 =new char[] {'J','A','V','A'};
//배열의 선언, 생성(암시적 배열 생성)ㅣ, 초기화
char[] ch3 = {'자','바'};
int[] array = {10,20,30,40,50};
//반복문을 이용해서 배열의 요소를 출력
for(int i=0; i<array.length; i++) {
System.out.println("array["+i+"]:"+array[i]);
}
int[] array = {10,20,30,40,50};
//개선된 로프 (확장 for문)
for(int num : array) {
System.out.println(num);
}