배열 선언
:
Type[] Name = new Type[length];
--?Type Name[] = new Type[length];
메모리의 길이를 한번 정하면 크기를 변경할 수 없다.
연속된 공간을 할당해주기 때문
참조 값 할당 : points = new int[3];
index를 통해 접근 가능
for-each with Array
:
가독성이 개선된 반복문, 배열 및 Collections 에서 사용
index 대신 직접요소(elements)에 접근하는 변수를 제공
naturally ready only(copied value)
사용법
:
int array[]={1,2,3,4,5};
for(int x : array){
선언문;
}