public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "abcdaa";
dups(str);
}
public static void dups(String str){
HashSet hs = new HashSet();
char[] ch = str.toCharArray();
for(int i=0; i < ch.length;i++){
hs.add(ch[i]);
}
System.out.println(hs);
}
The above code return Output: [a,b,c,d]
But I want to print the Set values into a string so I can return a string value return value looks like this:Expected Output: abcd