처음 List를 쓸때 언제는 앞에서 List쓸때가 있고 언제는 ArrayList 쓸때가 있길래 뭐지 했다
List<String> list = new ArrayList<>();
ArrayList<String> list = new ArrayList<>();
알고보니 둘다 잘되니까 똑같다 생각했는데
엄밀히 말하자면
List = 인터페이스, ArrayList=클래스
ArrayList <> 는 ArrayList<>();
밖에 될수없지만
List<>는
List<> list = new ArrayList<>();
List<> list = new LinkedList<>();
List<> list = new Vector<>();
이렇게 될수있다.
즉, List가 유연성이 더 크다고 보면된다
관계들은 다음과 같다
이렇게 표현할수 있다.
Set<> set = new HashSet();
Set<> set = new TreeSet();
Map<> map = new HashMap();
Map<> map = new Hashtable();
Map<> map = new TreeMap();
더자세한 내용은
컬렉션 프레임워크를 공부하자
'language > 자바' 카테고리의 다른 글
자바 Integer.parseInt() 진수 표현 (0) | 2022.01.19 |
---|---|
자바 2진수 앞에 0 출력 (0) | 2022.01.19 |
자바 String, StringBuffer, StringBuilder (0) | 2022.01.19 |
자바 Scanner nextLine 오류 buffer (0) | 2022.01.19 |
자바 2차원 배열길이 length (0) | 2022.01.19 |