I have a line like this one:
stackoverflow
And I would like to get the following output in Java (Android):
s***********w
Thus, we save the first and last letters, while others are replaced with this "*" sign. I want the string length to be the same from input to output.
Here is the code of the function that I have.
String transform_username(String username) {
I can get the first and last letter, but I really do not know how to put "*" in the middle of the word. I know that I could iterate over it, but this is obviously not a good solution.
source share