aabccdee
Find the used alphabets as abcde ?

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


Please Help Members By Posting Answers For Below Questions

What are the different tags provided in jstl?

553


How many bytes are a float?

510


Can we have two methods in a class with the same name?

585


What is meant by JVM? Is JVM platform independent or not?

579


What is the difference between JDBC 1.0 and JDBC 2.0?

2714






Can a list be null in java?

544


Can we have more than one package statement in source file ?

590


Is {a, n, d} a palindrome? If you are given a random string, is it a palindrome or not?

619


What is the static block?

585


What is a method in programming?

638


Is this valid in java ? Can we instantiate interface in java?

548


Give me some null interfaces in java?

605


How can we make string upper case or lower case?

602


Does importing a package imports its sub-packages as well in java?

554


What is java reflection api?

560