I want to remove duplicate String
values inside my String[]
, but I am not sure quite how to do that.
Heres an example:
public static void main(String[] args){
String[] listofWords = new String [5];
listofWords[0] = "BMW";
listofWords[1] = "Audi";
listofWords[2] = "Mercedes";
listofWords[3] = "Audi";
listofWords[4] = "BMW";
for(int i = 0; i<listofWords.length-1; i++){
system.out.println(listofWords[i]);
}
}
How would I got about deleting the duplicates in this array
and only have one of each make?