Guest User

Untitled

a guest
Jun 13th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. public class Wrapper {
  2. public static String wrap(String s, int col) {
  3. if (s.length() <= col)
  4. return s;
  5. int space = (s.substring(0, col).lastIndexOf(' '));
  6. if (space != -1)
  7. return (s.substring(0, space) + "\n" + wrap(s.substring(space+1), col));
  8. else
  9. return (s.substring(0, col) + "\n" + wrap(s.substring(col), col));
  10. }
  11. }
Add Comment
Please, Sign In to add comment