Question
/** * Returns true if and only if each string in the supplied list of strings * starts with an uppercase letter. If the list
/**
* Returns true if and only if each string in the supplied list of strings
* starts with an uppercase letter. If the list is empty, returns false.
*
* @param l a non-null list of strings
* @return true iff each string starts with an uppercase letter
*/
public static boolean allCapitalizedWords(List
int j = 0;
for(String string : l) {
char letter = string.charAt(0);
if(!Character.isUpperCase(letter)) {
j = 0;
break;
}
}
if(j == 0) {
return true;
}
else {
return false;
}
} =================================
/**
* Inserts a string into a sorted list of strings, maintaining the sorted property of the list.
*
* @param s the string to insert
* @param l a non-null, sorted list of strings
*/
public static void insertInOrder(String s, List
}
using get, set, add, size and the like instead of the array index operators []. For allCapitalizedWords, you may find Character.isUpperCasehelpful. For insertInOrder, you can use String.compareTo to determine which string comes first. If you have two strings s1 and s2, use s1.compareTo(s2) < 0 to check if s1 comes before s2.
Thank you!!!!!!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started