Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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
}
}

boolean contains (Links to an external site.)Links to an external site.(CharSequence (Links to an external site.)Links to an external site. s)

Returns true if and only if this string contains the specified sequence of char values.

Explanation / Answer

Following is the answer:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote