A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

在《学经济的审Java侵权案,甲骨文怒了》这篇资讯提到了 9 行 Java 代码,来看看:OpenJDK 中的那 9 行代码:
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
        if (fromIndex > toIndex)
            throw new IllegalArgumentException("fromIndex(" + fromIndex +
                       ") > toIndex(" + toIndex+")");
        if (fromIndex < 0)
            throw new ArrayIndexOutOfBoundsException(fromIndex);
        if (toIndex > arrayLen)
            throw new ArrayIndexOutOfBoundsException(toIndex);
     }
Google 用了的那 9 行代码:
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
        if (fromIndex > toIndex)
            throw new IllegalArgumentException("fromIndex(" + fromIndex +
                       ") > toIndex(" + toIndex+")");
        if (fromIndex < 0)
            throw new ArrayIndexOutOfBoundsException(fromIndex);
        if (toIndex > arrayLen)
            throw new ArrayIndexOutOfBoundsException(toIndex);
    }
这两段代码都是 Joshua Bloch 写的。Bloch 曾经在 Sun 公司写 Java API。2004 年他加入谷歌,2008年加入Android项目。不过,在谷歌工作时,他仍然在给由 Sun 公司控制的 OpenJDK 项目贡献代码。他的贡献之一,基于 TimSort 算法改进了数组排序的实现。旧算法和新算法中都有 rangeCheck 方法,所以他从旧实现中复制了,作为“a temporary measure”。

Joshua Bloch,Java 大牛。ImportNew 的粉丝都是 Java 程序员。如果你没有听过他的名字,那也肯定听过他的这本书《Effective Java》。早在1996年,适逢Java刚刚崭露头角。先是1月份发布JDK1.0,然后是5月底在旧金山召开首届JavaOne大会,年末又是JDK1.1紧跟其后。正是在Java技术如火如荼、大展拳脚的背景之下,JoshuaBloch来到了Sun。2004 年7月初,就在J2SE5.0发布在即,Jusha Bloch刚刚荣获Sun“杰出工程师(Distinguished Engineer)”的称号之时,他突然离开Sun而去了正值发展态势迅猛的Google,成为了Google的Java首席架构师。2012年8月,Bloch 离开了Google。

4 个回复

倒序浏览
技术交流,多好啊
回复 使用道具 举报
看一看。。。。。。。
回复 使用道具 举报
不错,不错,赞一个
回复 使用道具 举报
看不懂==
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马