public static String front3(String str) {
if (str.length() < 3)
return str + str + str;
else
return (str.substring(0, 3) + str.substring(0, 3) + str.substring(0, 3));
}
Function Call | Return Value | |||
---|---|---|---|---|
front3("aabbb") | → | |||
front3("baa") | → | |||
front3("abcabc") | → | |||
front3("a") | → | |||
front3("") | → |
Experiment with this code on Gitpod.io