Vector
import java.util.Vector;
public class VectorMain {
public VectorMain() {
VectorTest vt = new VectorTest();
Vector vv = vt.getVector();
Calculator cal = (Calculator)vv.elementAt(0);
//cal.start(); //계산기 출력
// 제너릭
Vector<String> vNameList = new Vector<String>();
vNameList.addElement(new String("harly"));
vNameList.addElement(new String("deadshot"));
vNameList.addElement(new String("diablo"));
vNameList.addElement(new String("joker"));
System.out.println("capacity="+vNameList.capacity()); //공간확보
System.out.println("size="+vNameList.size()); //객체수
vNameList.set(1, new String("suicide squad")); //다른 객체로 수정
vNameList.add(1, new String("boomerang")); //객체 추가
vNameList.insertElementAt(new String("katana"), 2); //객체 추가
//삭제성고 : true, 삭제실패 : false
boolean boo = vNameList.remove(new String("suicide squad")); //객체 삭제
if(boo){ //삭제 성공 시 실행
System.out.println("삭제 성공");
}else{ //삭제 실패 시 실행
System.out.println("삭제 실패");
}
//출력
for(int i=0; i<vNameList.size(); i++){
System.out.println("vNameList("+i+")="+vNameList.elementAt(i));
}
}
public static void main(String[] args) {
new VectorMain();
}
}