Post

Collection 컬랙션

  • 자료구조를 구체화해서 java에 놓여놓은 것

List 배열

추상적 자료구조, 순서가 있고 중복을 허용함 (Set 과 구별됨)

image

List 코드

1
2
3
4
5
6
7
8
9
// 실제 java.util의 List 코드
public interface List<E> extends Collection<E> { // 제네릭 인터페이스 
		int size();
    boolean isEmpty();
		...
		boolean addAll(Collection<? extends E> c);
		boolean add(E e);
		...
}      
  • 타입변수 E
  • addAll()메서드의 인자에 조건이 두개 들어있다.
    1. Collection 타입에 속하는 것
    2. List의 타입변수 E의 자손 클래스를 원소로 가지고 있을 것
This post is licensed under CC BY 4.0 by the author.