Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import java.util.Arrays;
  2.  
  3. public class WordArray
  4. {
  5. private String[] words;
  6.  
  7. public WordArray(String[] words) {
  8. this.words = words;
  9. }
  10.  
  11. public String titleCase() {
  12. String allTitleCase = "";
  13. for(int i = 0; i < words.length; i++) {
  14. String titleCase = words[i].substring(0,1).toUpperCase() + words[i].substring(1).toLowerCase();
  15. allTitleCase += titleCase + " ";
  16. }
  17. return allTitleCase;
  18. }
  19.  
  20. public String toString()
  21. {
  22. String s= "";
  23. for (String w : words)
  24. {
  25. s = s + w + " ";
  26. }
  27. return s;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement