class FirstUniqueCharFinder { static char find(String word) { int len = word.length(); char firstUniqueChar = 0; for (int i = 0; i < len; i++) { char currentChar = word.charAt(i); String after = word.substring(i + 1, len); if (!after.contains(Character.toString(currentChar))) { firstUniqueChar = currentChar; break; } } return firstUniqueChar; } public static void main(String[] args) { System.out.println(find("transaction")); System.out.println(find("reverse")); } }