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 new features in java 8? Explain

556


What is string args [] in java?

540


What are the differences between c++ and java?

581


What are the Static and Dynamic Variables? Differentiate them.

602


Explain treeset?

592






What is the default value of byte datatype in java?

486


Difference between this() and super() ?

580


What are the two types of streams offered by java 8?

510


What is the r character?

586


What are the states of thread in java?

512


What is the difference between numeric and integer?

510


What is the difference between yielding and sleeping?

556


What are benefits of java?

556


Is integer a class?

564


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

533