"Code for finding the first non repeating character of a given String"
class FindNonReaptingCharacter
{
/* This method returns index of the first non-repeating
character in a string. If all characters are repeating
then it returns -1 */
static int firstNonRepeatingCharacter(String str)
{
int index = -1, i;
for (i = 0; i < str.length(); i++)
{
for(j=0;j<str.length(); i++)
{
if (str.charAt(i)==str.charAt[j])
{
index = i;
break;
}
}
}
return index;
}
// Main Method
public static void main (String[] args)
{
String str = "mindstick.com";
int index = firstNonRepeatingCharacter(str);
System.out.println(index == -1 ? "Either all characters are repeating " : "First non-repeating character is : : " + str.charAt(index));
}
}