This can be done with two for loops as told by 'Wouter' . Try to implement the steps below. It will work for you.
1. For loop for 1st string array.
2. Inside the for loop add one for loop for the the 2nd string array.
3. inside that compare the element of 1st and 2nd array.
If true----> make both ""
if false----> do nothing
4. After that print the array as you are doing in your code.
The for each loop isn't a special construct. It's syntactic sugar. It gets compiled to something like the code I posted (I don't know the precise technical construct). And because of that the variable provided by the for each loop is just another reference to the element in the collection. And you can change that reference, like you're doing, but it won't change anything on the element in the collection.
Joined: Aug 23, 2010
use normal for loop instead for enhanced for loop in your last code. It will work.
In enhanched for loop the assignment will not work as you did.
Joined: Sep 25, 2010
Got there in the end; this works. Please could you advise how I could improve the quality of the source?