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 are the new features in java 8? Explain
What is string args [] in java?
What are the differences between c++ and java?
What are the Static and Dynamic Variables? Differentiate them.
Explain treeset?
What is the default value of byte datatype in java?
Difference between this() and super() ?
What are the two types of streams offered by java 8?
What is the r character?
What are the states of thread in java?
What is the difference between numeric and integer?
What is the difference between yielding and sleeping?
What are benefits of java?
Is integer a class?
can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread