这一行有点不明白,求助大神

public class Test85 {

  public static void main(String[] args) {
    String str = "Java是一种广泛使用的计算机编程语言,于1995年5月以Java的名称正式发布。";

    int index = str.indexOf("Java");

    index = str.indexOf("Java",index + 4);

    String newStr = str.substring(index + 4, index + 9);
    System.out.println(newStr);
  }

}

按要求打出第二个Java后五个字

str.indexOf("Java");从str字符串首开始向后找“Java”的位置,返回0,此时index=0

index = str.indexOf("Java",index + 4);从str字符串的第index+4位即第4位开始向后找”Java“,找出来的是第二个”Java“的位置

第8行是什么意思,有点不太明白这个含义,然后就是为什么去掉这一行的”java",就显示的是第一个Java的后五个字?

像java自带的函数,不懂的话可以看看API文档。https://docs.oracle.com/javase/8/docs/api/。IDE里导入JDK源码,也能很方便的查看。

public int indexOf(String str, int fromIndex)
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
The returned index is the smallest value k for which:

 k >= fromIndex  && this.startsWith(str, k)
 
If no such value of k exists, then -1 is returned.
Parameters:
str - the substring to search for.
fromIndex - the index from which to start the search.
Returns:
the index of the first occurrence of the specified substring, starting at the specified index, or -1 if there is no such occurrence.