Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String arrange(String sentence){
- String[] arr = sentence.substring(0,sentence.length()-1).split(" ");
- Arrays.sort(arr, Comparator.comparingInt(String::length));
- String res = new String("");
- for(String s : arr){
- res += s;
- res += " ";
- }
- res = res.substring(0,1).toUpperCase() + res.substring(1,res.length()-1).toLowerCase() + ".";
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement