Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. private String capitalize(String stringa) {
  2.  
  3. int i = 0;
  4. String comodo= null;
  5. String s= null;
  6. StringBuilder uppercase = null;
  7. int n= stringa.length();
  8. s = stringa.substring(0,1).toUpperCase()+stringa.substring(1,n).toLowerCase();
  9.  
  10. for (i = 0; i < s.length(); i++) {
  11.  
  12. if (s.charAt(i)==' ' && i < s.length()-1) {
  13. comodo = s.substring(i+1, i+2).toUpperCase();
  14. uppercase = new StringBuilder(s);
  15. uppercase.replace(i+1, i+2,comodo);
  16. s = uppercase.toString();
  17.  
  18.  
  19. }
  20. }
  21.  
  22.  
  23.  
  24. return s;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement