Hello! I'm a college student who is taking a beginners Java programming class. For the first time, I really need some assistance figuring out the latest assignment, which involves static methods. I have 5 such assignments, but I only need helping figuring out 1, because then I can do the other 4 on my own. Plus, the textbook (Java Software Solutions by Lewis & Loftus) didn't explain the concepts very well and I am quite lost...
To make things easier I'll post the assignment here, but can you only give me advice on how to get started? I'd greatly appreciate any help!!!
Assignment:
Part1
Write a method named replace that will accept 3 parameters: the original String, the search String, and the replace String. The method should return a new String that has all of the occurrences of the search String replaced by the replace String. For example, replace("Blue shoes are good shoes.", "shoe", "car") would return the String "Blue cars are good cars." The method header must be:
public static String replace (String original, String s, String r)
Part2
Write a Java program named Tester.java that contains a main method. Inside the main method, write statements that will call the methods from LabWork.java. You should try calling each method several times to make sure the method works for all possibilities.
I think the structure for LabWork.java should begin like this, but what to put in the body is where I'm having trouble:
import java.util.Scanner;
public class LabWork
{
public static String replace (String original, String s, String r)
{
// body
} // end replace method
} // end class