This demo will show you how to add elements in the Vector
GeSHi (java):
public class VectorTest {
public static void main
(String[] args
) {
for (int i = 0; i < 10; i++) {
int randomNumber =
(int) (( 1+
(Math.
random() *
10)));
v.add(randomNumber);
}
v.add("Random");
v.add("Text");
System.
out.
println("Vector contains: " + v
);
}
}
Created by GeSHI 1.0.7.20
Output:Vector contains: [8, 6, 1, 5, 5, 7, 2, 5, 5, 2, Random, Text]