您的位置:首页 > 编程语言 > Java开发

【Java】List的subList方法参数误导

2012-04-21 11:30 225 查看
以下是Source注释。

可以看到fromIndex是被包含的索引,toIndex是不被包含的索引。

按照通常的编程规则,参数的使用应该具有相同的或一致的含义,但这里虽然都是index,却有不同的解释,只有看到注释才能正常使用。

这是不是JDK Source的不严谨之处呢?

* @param fromIndex low endpoint (inclusive) of the subList

* @param toIndex high endpoint (exclusive) of the subList

* @return a view of the specified range within this list

* @throws IndexOutOfBoundsException for an illegal endpoint index value

* (<tt>fromIndex < 0 || toIndex > size ||

* fromIndex > toIndex</tt>)

*/

List<E> subList(int fromIndex, int toIndex);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: