hello guys! here is the task i have :
A sandwich is two pieces of bread with something in between. Return the
string that is between the first and last appearance of "bread" in the given string, or return the empty string "" if there are not two pieces of bread.
getSandwich("breadjambread") → "jam"
getSandwich("xxbreadjambreadyy") → "jam"
getSandwich("xxbreadyy") → ""
here is my code :
when code compiles, i get the melding :Exception:java.lang.StringIndexOutOfBoundsException: String index out of range: -5 (line number:16)" ( getSandwich("xxbreadyy") → "" " ).what i did wrong in a code, that this example didnt go via if (b == -1 || bsecond == -1 ){ return "";} statement? Thank you!