Delete comment from: Javarevisited
package com.pra.sss;
/*
* Vector v1 and V2 contain some common objects
* Create vector V3 which will contain all V1 and V2
* and common objects only once
* without using colletion framework functions
*/
import java.util.Vector;
public class VectorTest {
public static void main(String[] args) {
Vector v1 = new Vector();
Vector v2 = new Vector();
Vector v3 = new Vector();
/*Vector v1*/
v1.add("A");
v1.add("B");
v1.add("C");
v1.add("D");
/*Vector v2*/
v2.add("W");
v2.add("B");
v2.add("C");
v2.add("Z");
System.out.println("V1"+v1);
System.out.println("V2"+v2);
for(String ss : v1) {
v3.add(ss);
}
for (int i = 0; i < v1.size(); i++) {
for (int j = i; j < v2.size(); j++) {
if(v1.get(i).equals(v2.get(j))) {
break;
}
else{
v3.add(v2.get(j));
break;
}
}
}
System.out.println("v3:"+v3);
}
}
/*
output
V1[A, B, C, D]
V2[W, B, C, Z]
v3:[A, B, C, D, W, Z]
*/
Mar 19, 2014, 9:37:24 AM
Posted to 2 Ways to Combine Arrays in Java? Integer, String Array Copy Example