unique in java code example
Example: find unique from a string in java
public class String_FindtheUnique_4 {
public static void main(String[] args) {
String result1 = Unique("BBCCDDSSEEDDYUT");
System.out.println(result1);
String s = "BABABACDR";
String r = "";
for(String each : s.split(""))
r += ( (Collections.frequency(Arrays.asList(s.split("")), each)) ==1 ) ? each : "";
System.out.println(r);
}
public static String Unique(String str) {
String result1 ="";
for(String each : str.split(""))
result1 += ( (Collections.frequency(Arrays.asList(str.split("")), each)) ==1 ) ? each : "";
return result1;
}
}