JAVA 복습하기

서화진·2022년 8월 22일
0

JAVA 학습일지

목록 보기
13/13

1) array


package ch20;

public class ArrayTest {

	public static void main(String[] args) {

		

		int[] arr = new int[10];
		int total = 0;
		
		for(int i = 0, num = 1; i < arr.length; i++) {
		   arr[i] = num++;
		}
		
		for(int num : arr) {
			total += num;
		}
		
		System.out.println(total);
	} 

}


package ch20;

public class CharArrayTest {

	public static void main(String[] args) {

		
		char[] alpahbets = new char[26];
		char ch = 'A';
		
		for(int i = 0; i<alpahbets.length; i++) {
			alpahbets[i] = ch++;
		}
		
		for( char alpha : alpahbets) {
			System.out.println( alpha + "," + (int)alpha);
		}
	}

}

아직 개념정리가 덜 된 부분.

선생님따라 코딩을 하긴했는데.. 복습이 너무나도 필요하다!!

시간이 갈 수록 더더욱 새롭고 어려워지는 java,,^^

profile
초보 개발자 / 학습일지 : https://velog.io/@dinyyyyy

0개의 댓글