原谅我的愚蠢,但我想在下面的代码部分中知道:
String titleTag = "<title>";
String endTitleTag = "</title>";
int titleStart = line.indexOf(titleTag);
int titleEnd = line.indexOf(endTitleTag);
if (titleStart != -1 && titleEnd != -1)
{
String title = line.substring(titleStart + titleTag.length(),titleEnd);
if (checkTitleIfMatched(title)) {
System.out.println(String.format("%s - %s", title, location));
word.set(title);
context.write(word, location);
}
}
-1的作用是什么,我们为什么要做这个,比如说,比较?
先感谢您