Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. public static String arrange(String sentence){
  2. String[] arr = sentence.substring(0,sentence.length()-1).split(" ");
  3. Arrays.sort(arr, Comparator.comparingInt(String::length));
  4. String res = new String("");
  5. for(String s : arr){
  6. res += s;
  7. res += " ";
  8. }
  9. res = res.substring(0,1).toUpperCase() + res.substring(1,res.length()-1).toLowerCase() + ".";
  10. return res;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement