File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vector increase my adding indice to next

 
ghazanfar khan
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
}

}
 
ghazanfar khan
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
disregard my posting, i figure it out , i can use setElementAt instead of calling add ...

cheers
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic