Hello everyone
I am adding collection first element at position 2, which is fine and add it to my requeire position but when i add another at position 1, it moves my previos added collection to 3 but it must remain at the same position whihc i ve added mean postion 2, why it is doing so because i ve to recover these values at the end and if my indices change then it is big problem for me, is there any way around.
here is my sample code
import java.util.*;
public class VChk{
Vector store;
public VChk(){
store = new Vector(10);
store.setSize(10);
}
public void addingVal(int val, String str){
Vector v = new Vector();
v.addElement(str);
addingTOStore(val, v);
}
public void addingTOStore(int val, Vector v){
System.out.println("size "+ store.size());
store.add(val, v);
System.out.println(store);
}
public static void main(String [] arg){
VChk a = new VChk();
a.addingVal(2,"str2");
a.addingVal(1,"str1");
}
}
I am adding collection first element at position 2, which is fine and add it to my requeire position but when i add another at position 1, it moves my previos added collection to 3 but it must remain at the same position whihc i ve added mean postion 2, why it is doing so because i ve to recover these values at the end and if my indices change then it is big problem for me, is there any way around.
here is my sample code
import java.util.*;
public class VChk{
Vector store;
public VChk(){
store = new Vector(10);
store.setSize(10);
}
public void addingVal(int val, String str){
Vector v = new Vector();
v.addElement(str);
addingTOStore(val, v);
}
public void addingTOStore(int val, Vector v){
System.out.println("size "+ store.size());
store.add(val, v);
System.out.println(store);
}
public static void main(String [] arg){
VChk a = new VChk();
a.addingVal(2,"str2");
a.addingVal(1,"str1");
}
}