public static int firstUniqChar(String s) {
char[] a = s.toCharArray();
for(int i=0; i<a.length;i++){
if(s.indexOf(a[i])==s.lastIndexOf(a[i])){return i;}
}
return 1;
}
my 4 lines Java solution

Following this toward, you can think in another way like this:
class Solution {
public int firstUniqChar(String s) {
int res = s.length();
for(char i = 'a'; i <= 'z'; i++){
int index = s.indexOf(i);
if(index != 1 && index == s.lastIndexOf(i)){
res = Math.min(res, index);
}
}
return res == s.length() ? 1 : res;
}
}