有人可以通过示例帮助我理解这段代码。我一直在努力理解这段代码。
URLResource file = new URLResource("http://www.dukelearntoprogram.com/course2/data/manylinks.html");
for (String item : file.words())
{ String itemLower = item.toLowerCase();
int pos = itemLower.indexOf("youtube.com");
if (pos != -1) {
int beg = item.lastIndexOf("\"",pos);
int end = item.indexOf("\"", pos+1);
System.out.println(item.substring(beg+1,end));
我正在为 lastIndexOf、IndexOf 和 Substring 位而苦苦挣扎。
这是一个示例 YouTube 网址:
youtube.com/channel/UCUZHFZ9jIKrLroW8LcyJEQQ