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
What is try-with-resources in java?
If a class is declared without any access modifiers, where can the class be accessed?
Is vector synchronized in java?
What is append function?
What does i ++ mean in Java?
Why are arrays useful in java?
When do you get classcastexception?
Is list thread safe in java?
What is the byte order of byte buffer?
Explain thread life cycle in java?
explain local datetime api in java8?
How to change the priority of thread or how to set the priority of thread?
What is sortedmap in java?
How do you implement polymorphism in our day to day life?
What are parsing rules?