Trying to split a String in certain ways without changing the String(String embed, String payload) structure.
System.out.println(embedCenter("<<>>", "Yay")); // => <<Yay>>
This is how it should look, so putting "<<>>"
for embed and "Yay"
for payload should return <<Yay>>
, however for "()"
embed and "Yay"
Payload it should return "(Yay)"
and for ":-)"
embed and "Yay"
payload it should return ":Yay-)"
So I'm just starting to learn, and kinda stuck at this question - I've tried doing substrings but while I could get one of those results, I cant find a way to get all of them with the same method.
public static String embedCenter(String embed, String payload) {
return ""; //
}
public static void main(String[] args) {
System.out.println(embedCenter("<<>>", "Yay")); // => <<Yay>>
System.out.println(embedCenter("()", "Yay")); // => (Yay)
System.out.println(embedCenter(":-)", "Example")); // :Example-)