Java Vector class
Vector’s unique functions
Vector appears earlier, earlier than collections
1: Add functions
1 | public void addElement(Object obj);
|
Copy after login
2: Get the function
1 2 | public Object elementAt(int index);
public Enumeration elements();
|
Copy after login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | import java.util.Enumeration;
import java.util.Vector;
public class IntegerDemo {
public static void main(String[] args) {
Vector v = new Vector();
v.addElement( "hello" );
v.addElement( "world" );
v.addElement( "java" );
for (int i = 0; i < v.size(); i++) {
String s = (String) v.elementAt(i);
System.out.println(s);
}
System.out.println( "---------------" );
for (Enumeration en = v.elements(); en.hasMoreElements();) {
String s = (String) en.nextElement();
System.out.println(s);
}
}
}
|
Copy after login
Thank you for reading, I hope it can help everyone, thank you for your support of this site!
For more articles related to Java Vector class details and example codes, please pay attention to the PHP Chinese website!