I'm supposed to convert Hypertext for ex. :
<li><a href=”(insert url)”>Url Name</a></li>
into a string:
Url: (Insert Url)
but I don't know what's wrong with my code. Can't even get a word. This is what the console says: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
public void start() { String hyperLink = null; int position1; int position2; do { System.out.print("Hyperlink: "); hyperLink = input.next(); hyperLink = hyperLink.replace(" ", ""); position1 = hyperLink.indexOf("/\">"); position2 = hyperLink.indexOf("</a"); String name = hyperLink.substring(position1, position2); System.out.println(name + ": "); } while (continue());
What am I doing wrong?