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 to split arraylist elements in java?
What are namespaces in java?
What will be the default values of all the elements of an array defined as an instance variable?
What is the use of pattern in java?
What is a instance variable?
How do you pass by reference?
What is use of set in java?
What is a class component?
What is the use of put method?
What's the base class in java from which all classes are derived?
These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }
Difference between this() and super() ?
What exactly is methodology?
What is matcher in java?
How do you take thread dump in java?