Generic Vector with String
import java.util.Vector;
public class MainClass {
static void addCode(String code) {
if (!list.contains(code)) {
list.add(code);
}
}
static Vector<String> list;
public static void main(String[] arguments) {
String[] codes = { "alpha", "lambda", "gamma", "delta", "zeta" };
list = new Vector<String>();
for (int i = 0; i < codes.length; i++) {
addCode(codes[i]);
}
for (int j = 0; j < codes.length; j++) {
addCode(codes[j]);
}
for (String code : list) {
System.out.println(code);
}
}
}
Related examples in the same category