public static void main(String[] args) {
int arrayA[] = new int[5];
arrayA[0] = 1;
arrayA[1] = 1;
arrayA[2] = 1;
arrayA[3] = 3;
arrayA[4] = 0;
int arrayB[] = new int[5];
arrayB[0] = 1;
arrayB[1] = 0;
arrayB[2] = 0;
arrayB[3] = 3;
arrayB[4] = 3;
Set<Integer> arrayC = new HashSet();
for ( int i = 0; i < arrayA.length; ++i) {
for ( int j = 0; j < arrayB.length; ++j ) {
if(arrayA[i]==arrayB[j]){
arrayC.add( new Integer( arrayA[i] ) );
}
}
}
Iterator outPutArray = arrayC.iterator();
while (outPutArray.hasNext()) {
System.out.println(outPutArray.next());
}
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
23