int[] list;1. list = new int[5];
2. double[] costs = new double [100]
3. boolean flags[];
flags = new boolean[20];
4. String[] names = new String[10];
list[0] = 90;
int arrayLen = list.length;char[] ch;
ch = new char[4];
ch[0]-'J';
ch[1]-'a';
ch[2]-'v';
ch[3]-'a';
int[] list = {10,20,30,40,50}; //아래와 동일
int[] list = new int[]{10,20,30,40,50}; //크기 지정 안해도 뒤에보고 알 수 있음
int[] integers = null 하면 안됨
객체 배열에 대한 참조 변수 선언
Circle[] circles;
new 연산자로 객체 배열 할당
(각 요소는 Circle 타입의 객체를 가리키는 참조변수)
circles = new Circle[3];
circles[0] = new Circle(1);
circles[1] = new Circle(2);
circles[2] = new Circle(3);
Circle[] circles;
circles = new Circle[3]; //(참조변수)배열 만듦
circles[0] = new Circle(1); //요소 객체 만듦
circles[1] = new Circle(10);
circles[2] = new Circle();

String[] arr;
arr = new Strin[3];
arr[0] = "java" // new String("java");
arr[1] = "array" // new String("array");
arr[2] = "test" // new String("test");
// -> 암시적생성 / 명시적 생성
int i;
for (i=0;i<array.length; i++){
}
String[] arr = {"정지민", "홍정란", "정석원"};
for(String s: arr) // - arrr이 참조하는 배열요소 순차적으로 변수 s에 하나씩 전달
System.out.println(s);

public class CircleArrayTest {
static void initArray(Circle[] cs){
for (int i=0;i<cs.length;i++)
cs[i]=new Circle();
}
public static void main(String[] args){
Circle[] circles = new Circle[5]; //1차원 배열 만듦
iniArray(circles); //객체 할당 함수
for(Circle c: circles)
if (c !=null)
System.out.println(c.getRadius());
}
public class CircleArrayTest {
static Circle[] initArray(int n){ //동적 할당된 배열은 사라지지 않음
Circle[] cs = new Circle[n]; //1차원 배열 만듦
for (int i=0;i<n;i++)
cs[i]=new Circle();
return cs; // 참조값 반환
}
public static void main(String[] args){
Circle[] circles = iniArray(3); //객체 배열 생성, 요소값 할당 함수
for(Circle c: circles)
if (c !=null)
System.out.println(c.getRadius());
}
int[][] test1;
test1 = new int[2][3];
//test1.length ==2
//test[0].length ==3
int[][] test2;
test2= new int[2][];
test2[0] = new int[2]; //꼭 해줘야함!!
test2[1] = new int[4];
//test2.length == 2 //그룹 개수
//test2[0].length == 2 //요소 개수
//test2[1].length == 4


String[][] test3;
test3 = new String[2][]; //참조변수
test2[0] = new String[2];
test2[1] = new String[3]; //참조변수
test3[0][0] = new String("hi");
//각각 객체에 대한 참조를 대입함으로써 각 배열 요소 초기화 필요!
// [] : 배열 생성
// () : 객체 생성

int[][] array = {{1,3,5},{2,4,6}};

int i,j;
for (i=0;i<array.length;i++){
for (j=0;j<array[i].length; j++){
array[i][j]=new Array[1];
}
}