G
gbruno
Before you use java Vector class, try this code:
public void tevec() {
Vector dat;
int j;
dat = new Vector();
dat.clear();
System.out.print("adding " );
for (j = 0; j < 20; j++) {
System.out.print(" " + j );
dat.addElement(Integer.toString(j));
}
System.out.println(" looking ");
for (j = 0; j < 20; j++) {
System.out.print("at " + j + "..." + (String)dat.elementAt(j)
+ "...");
}
for (j = 0; j < 5; j++) {
dat.removeElementAt(j);
}
System.out.println(" after removing ");
for (j = 0; j < 5; j++) {
System.out.print("at " + j + "..." + (String)dat.elementAt(j)
+ "...");
}
System.out.println(" how bad is that? ");
} //
tevec______________________________________________________________________
adding 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 looking
at 0...0...at 1...1...at 2...2...at 3...3...at 4...4...at 5...5...at
6...6...at 7...7...at 8...8...at 9...9...at 10...10...at 11...11...at
12...12...at 13...13...at 14...14...at 15...15...at 16...16...at
17...17...at 18...18...at 19...19... after removing
at 0...1...at 1...3...at 2...5...at 3...7...at 4...9... how bad is
that?
public void tevec() {
Vector dat;
int j;
dat = new Vector();
dat.clear();
System.out.print("adding " );
for (j = 0; j < 20; j++) {
System.out.print(" " + j );
dat.addElement(Integer.toString(j));
}
System.out.println(" looking ");
for (j = 0; j < 20; j++) {
System.out.print("at " + j + "..." + (String)dat.elementAt(j)
+ "...");
}
for (j = 0; j < 5; j++) {
dat.removeElementAt(j);
}
System.out.println(" after removing ");
for (j = 0; j < 5; j++) {
System.out.print("at " + j + "..." + (String)dat.elementAt(j)
+ "...");
}
System.out.println(" how bad is that? ");
} //
tevec______________________________________________________________________
adding 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 looking
at 0...0...at 1...1...at 2...2...at 3...3...at 4...4...at 5...5...at
6...6...at 7...7...at 8...8...at 9...9...at 10...10...at 11...11...at
12...12...at 13...13...at 14...14...at 15...15...at 16...16...at
17...17...at 18...18...at 19...19... after removing
at 0...1...at 1...3...at 2...5...at 3...7...at 4...9... how bad is
that?