Can anyone please let me know how to remove duplicate values from
String s=\"Bangalore-Chennai-NewYork-Bangalore-Chennai\";
and output sh
import java.util.*;
public class RemoveDuplicateWord {
public static void main(String[] args) {
String str = "Hai hello Hai how hello are how you";
removeDupWord(str);
}
public static void removeDupWord(String input) {
List list = Arrays.asList(input.split(" "));
LinkedHashSet lhs = new LinkedHashSet(list);
for(String s : lhs) {
System.out.print(s+" ");
}
}
}