Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Words
- {
- /**
- Computes a string that repeats every letter 't' in the original string.
- @param s any string
- @return a string with the same characters as s, except that every letter 't' is repeated
- */
- public String stutter(String s)
- {
- String newStr = "";
- for(int i = 0; i < s.length(); i++)
- {
- if(s.charAt(i) == 't'){newStr += "tt";}
- else{newStr += s.charAt(i);}
- }
- return newStr;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement