Write a Java program that makes use of the following methods from the String cla
ID: 3916841 • Letter: W
Question
Write a Java program that makes use of the following methods from the String class:
Returns true if and only if this string contains the specified sequence of char values.
Tests if this string ends with the specified suffix.
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.
Converts all of the characters in this String to lower case using the rules of the default locale.
Starter Code (you can copy and paste):
public class StringFun
{
public static void main( String[] args )
{
String woodchuck = "How much wood would a woodchuck chuck if a wood chuck could chuck wood?";
String bard = "A fool thinks himself to be wise, but a wise man knows himself to be a fool.";
// Check if the first string contains "woodchuck"
System.out.println( woodchuck.contains( "woodchuck" ) );
// Check if the bard string contains "star"
// Check if the woodchuck string ends with "chuck wood"
// Check if the bard string ends with "fool"
// In string woodchuck, replace all instances of "woodchuck" with "groundhog"
// Display string bard in all lower case
}
}
Returns true if and only if this string contains the specified sequence of char values.
Explanation / Answer
Following is the answer:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.