I'm trying to remove duplicate elements from a String array. For example if the input was Yellow, Yellow, Red. The output would be Yellow, Red. What do I put inside the conditional? Is there a remove method in java? Here's the method I made:
public static String [] CompareAndDestroy(String [] array)
{
String [] newarray = new String [array.length];
for(int i = 0; i<array.length;i++)
{
for(int j = 0;j<array.length;j++)
{
if(array[i].compareTo(array[j])==0)
{
}
}
}
return array;
}