Question: package string.exercises; public class StringExercises { /** * Searches for Marc in a string. * * @param string a non-null string * @return the index

package string.exercises; public class StringExercises {

/**

* Searches for "Marc" in a string.

*

* @param string a non-null string

* @return the index of the first occurrence of "Marc" in string, or -1 if not found

*/

public static int findMarc(String string) {

return -2;

}

/**

* Searches for a substring within a string.

* @param string a non-null string

* @param substring a non-null string

* @return the index of the first occurrence of the substring within the string, or -1 if not found

*/

public static int findSubstring(String string, String substring) {

return -2;

}

/**

* Returns true if and only if the string contains the substring.

* @param string a non-null string

* @param substring a non-null string

* @return true if and only if the string contains the substring

*/

public static boolean contains(String string, String substring) {

return false;

}

/**

* Splits a string into words, using whitespace to delimit the words.

*

* See the assignment writeup for the magic argument to split().

*

* @param string a non-null string

* @return an array representing the words in the string.

*/

public static String[] splitIntoWords(String string) {

return null;

}

/**

* Returns the substring representing the first four characters of the string.

* @param string a non-null string of length >= 4

* @return the substring representing the first four characters of the string

*/

public static String firstFour(String string) {

return null;

}

/**

* Returns the substring representing the first n characters of the string.

* @param string a non-null string of length >= n

* @param n an integer >= 0

* @return the substring representing the first n characters of the string

*/

public static String firstN(String string, int n) {

return null;

}

/**

* Returns the substring representing the last four characters of the string.

* @param string a non-null string of length >= 4

* @return the substring representing the last four characters of the string

*/

public static String lastFour(String string) {

return null;

}

/**

* Returns the substring representing the last n characters of the string.

* @param string a non-null string of length >= n

* @param n an integer >= 0

* @return the substring representing the last n characters of the string

*/ public static String lastN(String string, int n) { return null; } }

you shouldnt need to write any loops to complete this file. Finally, note you can use the String.split method ===========================================================================================

package list.exercises; import java.util.List; public class ListExercises {

/**

* Counts the number of characters in total across all strings in the supplied list;

* in other words, the sum of the lengths of the all the strings.

* @param l a non-null list of strings

* @return the number of characters

*/

public static int countCharacters(List l) {

return 0; }

/**

* Splits a string into words and returns a list of the words.

* If the string is empty, split returns a list containing an empty string.

*

* @param s a non-null string of zero or more words

* @return a list of words

*/

public static List split(String s) { return null; }

/**

* Returns a copy of the list of strings where each string has been

* uppercased (as by String.toUpperCase).

*

* The original list is unchanged.

*

* @param l a non-null list of strings

* @return a list of uppercased strings

*/

public static List uppercased(List l) {

return null;

}

/**

* 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 l) {

return false;

}

/**

* Returns a list of strings selected from a supplied list, which contain the character c.

*

* The returned list is in the same order as the original list, but it omits all strings

* that do not contain c.

*

* The original list is unmodified.

*

* @param l a non-null list of strings

* @param c the character to filter on

* @return a list of strings containing the character c, selected from l

*/

public static List filterContaining(List l, char c) {

return null;

}

/**

* 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 l) {

}

} youll be using get, set, add, size and the like instead of the array index operators []

Translate written descriptions of behavior into code. thank you!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!