How to find all non repeating characters in a string with Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        String str = "c c++ csharp java php python";
        
        for (char ch :str.toCharArray()) {
            if (str.indexOf(ch) == str.lastIndexOf(ch)) {
                System.out.println(ch);
            }
        }
    }
}




/*
run:

s
r
j
v
y
t
o
n

*/

 



answered Sep 4, 2022 by avibootz

Related questions

1 answer 124 views
1 answer 135 views
1 answer 148 views
1 answer 131 views
1 answer 147 views
...