Answer Posted / hitesh
public static void main(String[] args) {
String s1 = "aaabbccccaaa";
String s2 = " ";
for (int i = 0; i < s1.length(); i++) {
if (i == 0) {
s2 = s2.concat("" + (s1.charAt(i)));
}
if (s2.contains(s1.charAt(i) + "")) {
continue;
} else {
s2 = s2.concat("" + (s1.charAt(i)));
}
}
System.out.println(s2);
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Give any two differences between C++ and java.
How do you reverse sort in java?
How many types of voids are there?
What is assembly used for?
What are scalar data types?
Does it matter in what order catch statements for filenotfoundexception and ioexception are written?
What is entry set in java?
Explain notifyall() method of object class ?
What is role of void keyword in declaring functions?
What is the collections api in java programming?
What is the difference between the prefix and postfix forms of the ++ operator?
What are peerless components?
What must a class do to implement an interface in java programming?
Explain about the select method with an example?
How to add menushortcut to menu item?