在一个字符串中找到第一个只出现一次的字符
public class MSX_Q7 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String str = scanner.nextLine();
System.out.println(findFirstNoDuplicatedChar(str) );
}
private static char findFirstNoDuplicatedChar(String str) {
for (int i = 0; i < str.length(); i++) {
if (str.lastIndexOf(str.charAt(i)) == str.indexOf(str.charAt(i))) {
return str.charAt(i);
}
}
return 0;
}
}
出处http://blog.csdn.net/beiyeqingteng/article/details/7447920