+2

How to find a single words in a String ?

Like as Input :- rarad Output :- d Input raraddmk Output mk

8/23/2019 3:49:24 PM

GOPAL Patidar

3 Answers

New Answer

+5

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

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.

+1

Use the indexOf method of the String class to search a string for a specified substring or character. See... https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#indexOf-java.lang.String-int- Don't reinvent the wheel. Read the docs instead.