daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top