// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class StringSearch {
    public static void firstNonRepeatingChar(String str) {
        char c;
        int pos = 0;
        int len = str.length();
        for (int i = 0; i < len; i++) {
            c = str.charAt(i);
            pos = str.indexOf(c);
            pos = str.indexOf(c, pos + 1);
            if (pos == -1) {
                System.out.println("non repeating char : " + c);
                break;
            }
        }
    }
    public static void firstNonRepeatingChar2(String str) {
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            int pos = str.indexOf(c);
            pos = str.indexOf(c, pos + 1);
            if (pos == -1) {
                System.out.println("2: non repeating char : " + c);
                break;
            }
        }
    }
    public static void test(String str) {
        firstNonRepeatingChar(str);
        firstNonRepeatingChar2(str);
    }
    public static void main(String[] args) {
        test("abcdxyzabc");
        test("abcdxyz");
        test("aa");
    }
}
