I have completed an implementation for finding the first unique character.
Is there any way I can improve it?
package com.datastructures;
public class FirstUniqueCharacter {
public static void main(String args[]){
String string = "neslihan";
System.out.println(firstUniqueChar(string));
}
private static int firstUniqueChar(String string) {
int freq[] = new int[26];
for(int i=0; i< string.length() ;i++){
freq[string.charAt(i) - 'a'] ++;
}
for (int j =0;j<string.length();j++){
;
System.out.println(string.charAt(j)-0);
System.out.println('a'-0);
if(freq[string.charAt(j) - 'a'] == 1) {
return j;
}
}
return -1;
}
}