Scroll to see replies
public String nTwice(String str, int n) {
int stringLength = str.length();
String firstChars = str.substring(0,n);
String lastChars = str.substring(stringLength-n);
return firstChars+lastChars; }
•
•
A String, used to hold a sentence to manipulate
•
•
Take a String as a parameter, and assigns its value to the class variable
•
•
Take a String as a parameter, and return a new String that removes the first instance of the parameterString from the class variable.
•
As an example, if the argument is "cat", and the class variable stores "A kittycat is at the door", then the class method should return "A kitty is at the door".
•
As a second example, if the argument is "d", and the class variable stores "Candy is bad for your teeth", then the class method should return "Cany is bad for your teeth".
•
Note, for the purpose of this question, you can ignore the case where the parameter String does not appear in the class variable. This involves material we'll look at in Topic 3.
Last reply 1 month ago
Free website hosting providers with no strings attached?Posted 3 months ago
iDEA silver citizen badge three. Milkshake shack coding problem.Last reply 4 months ago
How do you practice programming java for beginners?Last reply 8 months ago
hows the employment market for tech work in the UK?Last reply 1 month ago
Free website hosting providers with no strings attached?Posted 3 months ago
iDEA silver citizen badge three. Milkshake shack coding problem.Last reply 4 months ago
How do you practice programming java for beginners?Last reply 8 months ago
hows the employment market for tech work in the UK?