当前位置:首页 » 编程博文
开发技术指南» 文章正文
    引言: Here are some email b
 

 

    摘要:罗山尼亚安全公司bitdefender表示,它发现已经出现了针对便携式设备操作系统windows ce的第一例病毒。  bitdefender声称,它已经发现微软面向智能电话和其他便携设备而设计的windows ce操作系统正受到“理论上证实”的病毒的威胁。据了解,病毒的作者使用着“ratter”这一笔名,是专门编写symbian os病毒的组织29......
 ·在c#中应用mapobjects(渲染效果)    »显示摘要«
    摘要:在c#中应用mapobjects(渲染效果) 摘要:mapobjects c# 渲染 专题图 作者:杨雨田 blue_bat@126.com 以前用mapx,里面有专题图,挺好。经过几天的试验,我把mapobjects中的各种渲染效果(类似mapx专题图,但不一样)都试了试,下面附上源代码,如果那位有不懂的地方请自己琢磨,哈哈… 代码如下: using s......


我与 Joshua Bloch 的 email 讨论(emails between Joshua Bloch and me)
       here are some email between me and joshua bloch. i hope these email will do some help for you. these mail had been saved for some time. i think i can share them with you.

       joshua bloch, a senior staff engineer at sun microsystems, inc. bloch, an architect in the core java platform group, designed and implemented the award-winning java collections framework, the java.math package, and has contributed to many other parts of the platform. the author of numerous articles and papers, bloch has also written a book, effective java programming language guide, which won the prestigious jolt award from software development magazine. bloch holds a ph.d. in computer science from carnegie-mellon university. 【程序编程相关:从windows到linux —— 装l

       about joshua bloch, here is some information: 【推荐阅读:探索网络专业书店的经营模式(原创)

suggestion: 【扩展信息:blog系统存在问题,

       these email discussed about the general contract when overriding equals and java interface version ploblem. these questions were mentioned in the book effective java programming language guide.

after i read effective java (by joshua bloch mailto:joshua.bloch@sun.com), i find some questions. here are my suggestion:

1. in item 7: obey the general contract when overriding equals

"it turns out that this is a fundamental problem of

equivalence relations in object-oriented languages. there is simply no way to

extend an instantiable class and add an aspect while preserving the equals

contract."

i think we can modify function point.equals to do this, make it return true only when two object have the same class type.

public class point extends point2d implements java.io.serializable {

//...

    public boolean equals(object obj) {

        if (obj == null) {

            return false;

        }

        if (getclass().equals(obj.getclass()) == false) {

            return false;

        }

        point pt = (point)obj;

        return (x == pt.x) && (y == pt.y);

    }

}

public class colorpoint extends point {

    private color color;

    public colorpoint(int x, int y, color color) {

        super(x, y);

        this.color = color;

    }

    public boolean equals(object o) {

        if (obj == null) {

            return false;

        }

        if (getclass().equals(obj.getclass()) == false) {

            return false;

        }

        colorpoint cp = (colorpoint)o;

        return super.equals(o) && cp.color == color;

    }

}

there is no problem about symmetry or transitivity.

i suggest this should be a general rule for overwrite function equals().

2.in item 16: use interfaces insteadof abstract classes.


...   下一页
 ·arrays类的学习    »显示摘要«
    摘要:在论坛和生活中总是碰到不停的找java排序和查找算法的人,问哪里有源代码,呵呵。其实java本身给大家提供了一个很好的类,那就是arrays。arrays隶属书the collections framework。这个类提供了数组的填充,查找,比较,排序等一系列的对数组的操作。 一 填充: arrays.fill(type[] a, type val)系列方法是给,数组填充。就是简单的把一个数......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE