import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.Vector;
public class Practice {
public static void main(String[] args) {
List<String> arrayList = new ArrayList<String>();
List<String> vector = new Vector<String>();
List<String> linkedList = new LinkedList<String>();
arrayList.add("Java");
arrayList.add("Python");
arrayList.add("IntelliJ");
arrayList.add("Java");
vector.add("Java");
vector.add("Python");
vector.add("IntelliJ");
vector.add("Java");
linkedList.add("Java");
linkedList.add("Python");
linkedList.add("IntelliJ");
linkedList.add("Java");
System.out.println("ArrayList : " + arrayList.toString());
System.out.println("Vector : " + vector.toString());
System.out.println("LinkedList : " + linkedList.toString());
System.out.println();
for (int i = 0; i < arrayList.size(); i++) {
System.out.println("ArrayList " + i + "번 인덱스 : " + arrayList.get(i));
}
System.out.println();
Set<String> hashSet = new HashSet<String>();
Set<String> linkedHashSet = new LinkedHashSet<String>();
Set<String> treeSet = new TreeSet<String>();
hashSet.addAll(arrayList);
linkedHashSet.add("iPod");
linkedHashSet.add("Apple");
linkedHashSet.add("Red");
linkedHashSet.add("Apple");
treeSet.add("iPod");
treeSet.add("Apple");
treeSet.add("Red");
treeSet.add("Apple");
System.out.println("HashSet : " + hashSet.toString() + " 순서 유지 X");
System.out.println("LinkedHashSet : " + linkedHashSet.toString() + " 순서 유지 O");
System.out.println("TreeSet : " + treeSet.toString() + " 자동 정렬");
System.out.println();
Iterator<String> iter = hashSet.iterator();
for (int i = 0; i < hashSet.size(); i++) {
System.out.println(iter.next());
}
System.out.println();
Iterator<String> iterator = linkedHashSet.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
}
System.out.println();
Map<String, Integer> hashMap = new HashMap<String, Integer>();
Map<String, Integer> hashTable = new Hashtable<String, Integer>();
Map<String, Integer> linkedHashMap = new LinkedHashMap<String, Integer>();
hashMap.put("Samsung", 125);
hashMap.put("Apple", 154);
hashMap.put("LG", 99);
hashTable.put("Samsung", 125);
hashTable.put("Apple", 154);
hashTable.put("LG", 99);
linkedHashMap.put("Samsung", 125);
linkedHashMap.put("Apple", 154);
linkedHashMap.put("LG", 99);
System.out.println("HashMap : " + hashMap.toString());
System.out.println("HashTable : " + hashTable.toString());
System.out.println("linkedHashMap : " + linkedHashMap.toString());
System.out.println();
Set<String> mapKey = hashMap.keySet();
Iterator<String> iterKey = mapKey.iterator();
System.out.println(hashMap.get(iterKey.next()));
System.out.println(hashMap.get(iterKey.next()));
}
}