|
Home
Site Map Useful Tools Graphing Calc Scientific Calculator |
Introduction to String ProjectsThese methods are suitable for someone who is just beginning to work with strings and require understanding of concatenation, as well as the String's indexOf() and equals() methods.Write the body for the methods described below.
public String concatTwice(String str)
Description: This method returns str concatenated with itself .
public String concatWithComma(String str)
Description: This method returns str concatenated with itself and with a comma in between
public String sandwich(String bread, String meat)
Description: This method is easiest to understand by looking at the sample calls below
public int lengthTimesTwo(String str)
Description: This method returns the length of str times 2.
public boolean isAThere(String str)
Description: This method returns true if the letter "a" is anywhere inside of str . Note: You should use indexOf(). Remember, indexOf() return -1 if it is searching for something that is not there.
public boolean isThere(String str,String letter)
Description: This method returns true if letter is anywhere inside of str . Note: You should use indexOf().
public boolean sameStrings(String string1 ,String string2)
Description: This method returns true if string1 and string2 are the same. Use the '.equals()' method.
Challenge Methods.
public String concat5Times(String str)
Description: This method returns str concatenated with itself 5 times (Do this with a loop)
|