find first Non Repeat Character in String in java

find first Non Repeat Character in String
SOURCE : FirstNonRepeat.java



public class FirstNonRepeat {

/**
* @param args
*/
public static void main(String[] args) {
String a="aaabbcddeeh";
char b[]= a.toCharArray();
int i=0, j=0;
for(i=0,j=i+1;i {
while(b[i]==b[j])

{
j++;
}
if(b[j]==b[j+1])
{
i=j;
continue;
}
else
break;
}
System.out.println(b[j]);
}
}






INPUT

String a="aaabbcddeeh";



OUTPUT

c







Sandeep Kumar D

Hi, I have written and developed this post so that most of people will be benefited. I'm committed to provide easy and in-depth tutorials on various technologies.I hope it will help you a lot.

- Sandeep Kumar D

Follow Me @Google+




SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment