Vector
: ArrayList와 동일한 구조를 가지며 배열의 크기가 늘어나고, 줄어듬에 따라서 자동으로 크기가 조절된다.
항상 동기화되어있으며 collection 프레임워크에 없는 메서드들의 사용이 가능하지만,
스레드가 아닌 환경에서는 거의 사용되지않는다.
vector를 선언하는 방법은
Vector<String> vector = new Vector<>(); 이다.
(Integer, Character, Class 등 다양한 타입으로도 선언 가능)
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector;
import java.util.stream.Stream;
public class TestEx1 {
public static void main(String[] args) {
Vector<String> vv = new Vector<>();
vv.add("홍길동");
vv.add("홍길순");
vv.add("홍길철");
//1
Stream<String> st = vv.stream();
st.forEach(n->System.out.println(n));
System.out.println();
//2
Iterator<String> it = vv.iterator();
while(it.hasNext()) {
String ss = it.next();
System.out.println(ss);
}
System.out.println();
//3
Enumeration<String> es = vv.elements();
while(es.hasMoreElements()) {
String ss = es.nextElement();
System.out.println(ss);
}
}
}
값은 vv.add(" "); 로 추가하고,
그냥 System.out.prinln(); 로 출력해도 되지만 세 가지 방법으로 출력해보았다.
각각의 방법으로 프린트문을 작성했지만, 모두 같은 값이 나온다.
'22.05.24~22.11.16 > 7月' 카테고리의 다른 글
07-26 <Oracle> : view 와 index 생성, 삭제 (0) | 2022.07.26 |
---|---|
07-14 <JSP> : 쿠키 생성, 목록, 변경, 삭제 (0) | 2022.07.14 |
07-13 <Oracle> : 집계함수 (0) | 2022.07.13 |
07-12 <JSP> : 액션 태그 ( jsp:include, include 디렉토리, jsp:forward) (0) | 2022.07.12 |
07-01 <오라클> : 숫자 함수, 날짜 함수, 산수 (0) | 2022.07.08 |