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 different tags provided in jstl?
How many bytes are a float?
Can we have two methods in a class with the same name?
What is meant by JVM? Is JVM platform independent or not?
What is the difference between JDBC 1.0 and JDBC 2.0?
Can a list be null in java?
Can we have more than one package statement in source file ?
Is {a, n, d} a palindrome? If you are given a random string, is it a palindrome or not?
What is the static block?
What is a method in programming?
Is this valid in java ? Can we instantiate interface in java?
Give me some null interfaces in java?
How can we make string upper case or lower case?
Does importing a package imports its sub-packages as well in java?
What is java reflection api?