一个解析html文档程序中有这么一段代码:
        private String checkEnding(String link)
        {
                // Check if the link ends in html, htm, or /. If not, add a slash
                int l1 = link.indexOf("html");
                int l2 = link.indexOf("htm");
                int l3 = link.indexOf("php");
                int l4 = link.indexOf("jsp");
                return link;
        }
用来验证字符串的结尾,查看indexOf函数说明,它只是返回子字符串的位置,难道它还修改了原字符串也就是link字符串?还有上面的操作可以完成// Check if the link ends in html, htm, or /. If not, add a slash这个功能吗?
感觉这个函数好像什么也没有做,没有完成check功能,给个字符串然后再返回一个一个字符串,是这样吗?