How to First Non-Repeating Character of String

In this example, we’ll find the first non-repeating character of string:

Input:
String s = "HHello";

Output:
First non repeat character = e

1. Java

public class FirstNonRepeatingCharacterOfString {
    public static void main(String[] args) {
        String s = "HHello";
        for (Character ch : s.toCharArray()) {
            if (s.indexOf(ch) == s.lastIndexOf(ch)) {
                System.out.println("First non repeat character = " + ch);
                break;
            }
        }
    }
}

Output:

First non repeat character = e

Complete Java Solutions can be found here: Github Link

The complete list can be found here: Practise Programming Questions