ArrayList
import java.util.ArrayList;
ArrayList<Integer> arrayList1 = new ArrayList<>();
ArrayList<String> arrayList2 = new ArrayList<>();
ArrayList<Double> arrayList3 = new ArrayList<>();
ArrayList 메소드
add**( element )
ArrayList 맨뒤에 요소 추가add**( index, element )
index 위치에 요소 삽입addAll**( ArrayList )
ArrayList 뒤에 ArrayList 추가size**()
ArrayList의 길이 리턴get**( index )
index에 해당하는 요소 리턴indexOf**( params )
params와 같은 첫번째 요소의 index 리턴, 없으면-1 리턴remove**( index )
index의 요소삭제clear**()
모든 요소 삭제ArrayList 출력
// rect 인스턴스의 배열 생성
**ArrayList**<Rectangle> rects = **new ArrayList<>();**
// 반복문으로 가로 세로 길이 입력
while (true) {
int width = scanner.nextInt();
int height = scanner.nextInt();
if (width == 0 && height==0) break;
// rect 객체 생성
Rectangle rect = new Rectangle(width,height);
rects.add(rect);
//rects.add(new Rectangle(width,height));
}
// 각 객체의 인스턴스 변수값 출력
for (**Rectangle value: rects**) {
System.out.println("가로 길이는: "+ value.getWidth());
System.out.println("세로 길이는: "+ value.getHeight());
System.out.println("넓이는 : "+ value.recMethod());
}