you can make a loop for each letter index in input, and inside it another loop for iterating over each letter of input(except index of character outer loop) if same character found then break; else when reach last index in inner loop just print that character
1. Turn the string into an array.
2. Iterate through the character array and find the characters you need.
3. If it's a single character (like your 1st example), print them directly. Concat multiple characters (like your 2nd example) using +""+ when printing.
Use the indexOf method of the String class to search a string for a specified substring or character. See...
Don't reinvent the wheel. Read the docs instead.