java - How do I make a word repeat? -
This question is already an answer here
- 4 replies
I have a word too Repeat in java three times with return statement. I want to see it as "wordwordword" apart from how will I make a different method so that each letter can be repeated 3 times? So that it looks like "wwwooorrrddd" here i have so far (i also need to use a return statement)
public static void {String [] args) {system. Out.println (repeatText ("bar")); Println (changeText ("bar")); } Public Static String Repeated Text (String Text) {String Temp = ""; For (int i = 0; i & lt; text.length (); i ++) temporary + = text; Return temporary; } Fixed string change text (string text) {string tag = ""; For (int i = 0; I & lt; text.length (); i ++) for (int j = 0; j & lt; text.length (); j ++) temporary + = text.substring (I, I + 1); Return temporary; }
Comments
Post a Comment