aabccdee
Find the used alphabets as abcde ?
Answers were Sorted based on User's Feedback
Answer / vikas
1. Split the String into a String array.
2. Iterate over the String Array and add values into a Set(Duplicate values are not allowed).
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / 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 |
Answer / deepu
package com.thread;
import java.util.*;
public class Test2 {
public static void main(String[] args) {
String str="aabbbcdabbheaa";
char[]chs=str.toCharArray();
List l1=new ArrayList();
for(Character ch:chs){
l1.add(ch);
}
Set s1=new TreeSet(l1);
System.out.println(s1);
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / adarsh
Scanner sc=new Scanner(system.in);
Int i,j=0;
String S1=sc.next(),s2;
S2=s1charAt(0);
For(i=1;i<s1.length;i++)
{
If(s2.charAt(j).equals (s1.charAt(i))
Continue;
Else{
S2=s2.concat(s1.charAt(i));
j++;
}
}
Sop(j);
}
I m writing with my mobile phone so chuck the mistakes like upercase nd lowr case...
Is This Answer Correct ? | 1 Yes | 1 No |
What are runtime exceptions?
What is package protected in java?
how cani read a command line argument?(usingfile object).
What are the steps involved to write rmi based programs?
Will the jvm load the package twice at runtime?
Why collection is called framework in java?
i need income tax program using java inheritance concept. could u please help me?
What is the use of bin and lib in JDK?
INTERVIEW QUESTION FOR ANDROID
What is deadlock and how to avoid this?
explain the classification of exception and hoew to handle the exceptions
What are the types of methods in java?