import java.util.*;
//class RemoveDuplicateCharatcersFromString = Main9
class Main9
{
public static String removeDuplicates(String s) {
StringBuilder build = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
String st = s.substring(i, i + 1);
if (build.indexOf(st) == -1) {
build.append(st);
}
}
return build.toString();
}
public static void main(String[] args)
{
String str="AAA BBB ";
String newString=removeDuplicates(str);
System.out.println(newString);
}
}
out put:-
A B
Subscribe to:
Post Comments (Atom)
What is Map Collection?
A map collection refers to a set of maps that are compiled and organized for a specific purpose, such as research, education, or preservatio...
-
Mapping of classes can be made into a proxy instead of a table. A proxy is returned when actually a load is calle...
-
For any communication with DB, hibernate converts each HQL query to the equivalent SQL query with the configuration based in hbm.xml file to...
-
HQL is nothing but object oriented query language which is very similar to SQL. HQL is used for communication with DB. It supports almost a...
this question asking for me interview.......
ReplyDelete