Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- public class WordArray
- {
- private String[] words;
- public WordArray(String[] words) {
- this.words = words;
- }
- public String titleCase() {
- String allTitleCase = "";
- for(int i = 0; i < words.length; i++) {
- String titleCase = words[i].substring(0,1).toUpperCase() + words[i].substring(1).toLowerCase();
- allTitleCase += titleCase + " ";
- }
- return allTitleCase;
- }
- public String toString()
- {
- String s= "";
- for (String w : words)
- {
- s = s + w + " ";
- }
- return s;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement