ArrayList<타입 매개변수> 객체명 = new ArrayList<타입 매개변수>(저장용량); // 저장 용량은 변동 가능
ArrayList<String> arrayList = new ArrayList<>();
// 데이터 추가
arrayList.add("Java");
// 인덱스 0번 출력
arrayList.get(0);
// 인덱스 0번 삭제
arrayList.remove(0);
Arraylist<String> linked = new LinkedList<>();
검색에 있어 ArrayList에 비해 느림
ArrayList<String> list = ...
Iterator<String> iterator = list.iterator(); // list 객체 순회
while(iterator.hasNext()){// 읽어올 객체가 있다면 (true)
String str = iterator.next(); // next() 통해 다음 객체 읽어오기
Hashset<String> lang = new HashSet<String>();
TreeSet<String> employees = new TreeSet<>();
기본 정렬 방식 : 오름차순
하나의 부모에 최대 두 개의 자식 노드 연결되는 이진트리의 일종
최상위 노드를 루트라 한다.
(왼쪽 자식 < 부모,루트 || 오른쪽 자식 > 부모,루트)의 특징
<HashMap<String, integer> hashmap = new HashMap<>();
public class HashMapSample{
public static void main(String[] args){
//HashMap 생성
HashMap<String, Integer> map = new HashMap<>();
//Entry 객체 저장
map.put("아메리카노",2000);
map.put("카페라떼",3000);
//객체 찾기
System.out.println("아메리카노 : ", map.get("아메리카노"));
//Key set 생성
Set<String> KeySet = map.keySet();
//value 읽어오기
Iterator<String> keyIterator = keySet.Iterator();
while(keyIterator.hasNext()){
String key = keyIterator.next();
Integer value = map.get(key);
System.out.println(key + " " +value);
}
// 객체 삭제
map.remove("아메리카노");
// 객체 전체 삭제
map.clear();