I was able to get the two arrays to sort and merge but I can not figure out how to remove the duplicates. Can someone please help me with this? Here is my code so far:
public class FinalArray {
public static void main(String[] args) {
String[] testArray1 = {"coffee", "tea", "water"};
String[] testArray2 = {"lemonade", "juice", "water"};
mergeUniqueValues(testArray1, testArray2);
}
public static void mergeUniqueValues(String[] arr1, String[] arr2) {
String[] arr3 = new String[arr1.length + arr2.length];
for (int i = 0; i < arr1.length; i++) {
arr3[i] = arr1[i];
}
for (int i = arr1.length, index = 0; i < arr1.length + arr2.length; i++, index++) {
arr3[i] = arr2[index];
}
Arrays.sort(arr3);
System.out.println("Your sorted array is: ");
for (String str : arr3) {
System.out.println(str);
}
}
}