milliebbbrown
14.04.2020 •
Computers and Technology
Write a method appendIfMissing which is passed a String s and a String e (for ending). If s doesn't already end with e, the method returns a new String which consists of the contents of s concatenated with e. It returns s otherwise.
For example, if s refers to the String "lightningbug" and e refers to the String "bug", the method returns "lightningbug".
If s refers to the String "Airplane II", and e refers to the String ": the Sequel", the method returns "Airplane II: the Sequel".
Solved
Show answers
More tips
- F Family and Home How to Raise a Genius? Discover the Secrets Here...
- F Food and Cooking How to Properly Cook Buckwheat?...
- H Health and Medicine How to Tan in a Tanning Bed? Tips and Recommendations...
- S Style and Beauty How to Sew a Balloon Skirt: Detailed Tutorial and Tips on Choosing the Right Fabric...
- P Philosophy Personal attitude towards Confession: how to prepare and undergo the procedure correctly?...
- F Food and Cooking How to Make Cottage Cheese at Home: Simple and Quick Recipe with Step By Step Instructions...
- H Health and Medicine Which Water Are You Drinking? Is it Worth Buying Bottled Water?...
- H Health and Medicine What Makes a Man a Man?...
- H Health and Medicine What to Take with You to the Maternity Hospital?...
- F Food and Cooking What Foods Can Nursing Moms Eat?...
Answers on questions: Computers and Technology
- M Mathematics 1-36. if the perimeter of the rectangle at right is 112 cm, which equation below represents this fact? once you have selected the appropriate equation, solve for x. homework 4x...
- M Mathematics The number of members f(x) in a baseball club increased by 45% every year over a period of x years. the function below shows the relationship between f(x) and x: f(x) = 25(1.45)x...
- M Mathematics Please help asap, shehhrhd...
Ответ:
public static String appendIfMissing(String s, String e){
if(!s.endsWith(e))
return s+e;
return s;
}
Explanation:
Create a method called appendIfMissing takes two strings, s and e
Inside the method, check if s ends with e - using endsWith method. If it is, append the to s and return the new string. Otherwise, return only the s
*string1.endsWith(string2) method checks if the string1 ends with string2 and returns either true or false.
Ответ:
a d e
Step-by-step explanation: