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
How do you sort data in java?
How to calculate the length of a singly linked list in java?
How to create a thread in java?
What do you mean by of string::valueof expression in java 8?
How much is a java license?
What is the purpose of finalization in java programming?
What is a stringbuilder?
Where will it be used?
What is main function purpose?
Define how does a try statement determine which catch clause should be used to handle an exception?
What is tochararray in java?
What is difference between jdk,jre and jvm?
What is arraylist e?
What is dynamic array in java?
How does finally block differ from finalize() method?