How to find first non-repeated character in a given String in Java

By | August 8, 2018

In this post we will learn How to find first non-repeated character in a given String in Java with/without using Java inbuilt API or data structure.

We will look three approaches to solve this problem statement.

  1. Without using any in-built API or data structure
  2. Using LinkedHashMap data structure
  3. using String class indexOf(int ch) and lastIndexOf(int ch) methods

Approach 1:

Approach 2:

Approach 3:

I have checked all the above programs for few inputs as below. You may check for other input as well 

That’s all about  this topic How to find first non-repeated character in a given String in Java.

You May Also Like:

Reverse a string in Java (6 Different Ways)
Splitting a String in Java using a delimiter
Count number of words in a string java
Count total number of times each character appears in the string in java
Check if two strings are anagrams or not in java
How to convert string to int without using library functions in java
Check Whether a Given String/Number is a Palindrome in java
Java Program to find the frequency of each character in String ?

If you have any feedback or suggestion please feel free to drop in blow comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *