Programming/Java2014. 3. 18. 18:17
collection은 cpp로 치면.. STL?
제너릭스(generics)를 이용해서 만든 자료구조이다.

Set  / List / Queue / Map이 주로 사용되며,
4개는 interface로 implement 되어 각각에 대해 패키지를 제공하게 된다.
Set - HashSet / TreeSet
List - Stack / Vector / ArrayList
Queue - LinkedList
Map - HasMap

[링크 : http://docs.oracle.com/javase/7/docs/api/java/util/Set.html]
    [링크 : http://docs.oracle.com/javase/7/docs/api/java/util/HashSet.html]
[링크 : http://docs.oracle.com/javase/7/docs/api/java/util/List.html]
    [링크 : http://docs.oracle.com/javase/7/docs/api/java/util/Stack.html]
    [링크 : http://docs.oracle.com/javase/7/docs/api/java/util/Vector.html]
    [링크 : http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html]
[링크 : http://docs.oracle.com/javase/7/docs/api/java/util/Queue.html]
    [링크 : http://docs.oracle.com/javase/7/docs/api/java/util/LinkedList.html]
[링크 : http://docs.oracle.com/javase/7/docs/api/java/util/Map.html]
    [링크 : http://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html]

[링크 : http://docs.oracle.com/javase/tutorial/collections/interfaces/index.html]
[링크 : http://docs.oracle.com/javase/tutorial/collections/implementations/index.html]


>>>>
set(interface)
-> HashSet / TreeSet(implements)
set - 정렬되지 않음 / 중복 허용하지 않음 (대소문자 구별함)

>>>>
 List(가장 많이 씀 / array와 유사함)
- Stack / Vector / ArrayList (stack은 별로 사용하지 않음)

Stack - push / pop

Vector
 new Vector<String>(2,5) // 초기 2개, 확장 시 5개씩 확장
contains() remove() cacacity() size()
trimToSize() // 메모리 공간 줄이기

>>>>
Queue
- LinkedList 
offer() // push() 개념
poll() // pop() + 삭제

collection - interface
collections - class

>>>>>>
Map
-  HashMap
put()// 저장
get() // 꺼내기

ArrayList / HashMap을 많이 씀

Iterator(반복자)
- hasNext() remove()

---
2014.03.21 추가
결국에 Collection 하위는 Collection과 Iterable의 상속관계이며
toArray를 통하거나 Iterator를 통해서 상호 변환이 가능하다.

public interface Collection<E> extends Iterable<E>
- Object[] toArray()
- <T> T[] toArray(T[] a)
Iterator<E> iterator()
=======================================================
public interface Iterator<E>
- boolean hasNext()
- E next()
- void remove()
=======================================================


public interface Set<E> extends Collection<E>
public interface List<E> extends Collection<E>
public interface Queue<E> extends Collection<E>
public interface Deque<E> extends Queue<E>
public interface Map<K,V>
=======================================================
>> public interface Set<E> extends Collection<E>
public abstract class AbstractSet<E> extends AbstractCollection<E> implements Set<E>
public class HashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable, Serializable
public class TreeSet<E> extends AbstractSet<E> implements NavigableSet<E>, Cloneable, Serializable
public class LinkedHashSet<E> extends HashSet<E> implements Set<E>, Cloneable, Serializable

>> public interface List<E> extends Collection<E>
public class Vector<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, Serializable
public class Stack<E> extends Vector<E>
public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, Serializable
public class LinkedList<E> extends AbstractSequentialList<E> implements List<E>, Deque<E>, Cloneable, Serializable 


 

'Programming > Java' 카테고리의 다른 글

java thread  (0) 2014.03.19
java 날짜 관련 패키지  (0) 2014.03.19
java generic  (0) 2014.03.18
java static import  (0) 2014.03.17
java inner class / anonymous class  (0) 2014.03.17
Posted by 구차니