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 the difference between preemptive scheduling and time slicing? : Java thread
What is the similarity between dynamic binding and linking?
Which of the following is not an isolation level in the JDBC
Why there are some null interface in java? What does it mean?
Is an empty arraylist null?
Write a regular expression to validate a password. A password must start with an alphabet and followed by alphanumeric characters; its length must be in between 8 to 20.
What is the hashcode () and equals () used for?
What is complexity in java?
What is a flag variable?
Can you extend main method in java?
How does remove work in java?
Is string an object?
What is difference between this and super keyword?
Can an interface have a constructor?
what is the difference between thread and runnable types? : Java thread