当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: Implementing equalsDiscussion:Al
 

 

 ·java 基础数据类型     »显示摘要«
    摘要:1.简单数据类型 逻辑类型 boolean 文本类型 char,string(特殊类型) 整数类型 byte,short,int,long 浮点类型 double,float boolean 两个值:true and false char 16位无符号(不分正负的)unicode字符 必须包含在单引号内() eg:\t 表示一个制表符 \u???? 表示一个特殊的unicode字符 ????应严格......
    摘要:首先实现一个dbaccount类,完成数据库连接细节,这里使用的是mysql,你可以自行设计一个输入界面来获取用户输入的数据库连接参数:class dbaccount{ //数据库路径 string thedbname; //用户名 string theuserid; //帐户 string thepasswd; dbaccount(){ thedbname="jdbc:mysql://......


覆盖equals【引自http://www.javapractices.com/Topic17.cjp】
implementing equalsdiscussion:all objects have both identity (the objects location in memory) and state (the objects data). the == operator always compares identity. the default implementation of equals compares identity as well.

sometimes the default implementation of equals has the desired behaviour (as in a type-safe enumeration, for example), but  equals should usually compare state, not identity. this is particularly true for "data-centric" classes which map to database records.

if you override equals, you must override hashcode hashcode must generate equal values for equal objects objects placed in a list , set, or map (as either a key or value) should have an appropriate definition of equals. (see, for example, the javadoc for java.sun.com/j2se/1.5.0/docs/api/java/util/collection.html#contains(java.lang.object)">collection.contains , java.sun.com/j2se/1.5.0/docs/api/java/util/map.html#containskey(java.lang.object)">map.containskey, and java.sun.com/j2se/1.5.0/docs/api/java/util/map.html#containsvalue(java.lang.object)">map.containsvalue .)

if you extend a concrete class, and add a new field which contributes to equals, then it is not possible to write a perfectly correct equals method for the new class. instead, you should use composition instead of inheritance. 【程序编程相关:ANT介绍及安装及配置

hashcode and equals are closely related : 【推荐阅读:十分钟在jb里面运行hibernate的

here is an implementation of equals for a data-centric class. it demonstrates how different types of fields are treated: 【扩展信息:介绍下简单模版eastm

example


...   下一页
 ·jboss to websphere 迁移问题     »显示摘要«
    摘要:jboss to websphere 迁移问题近日做了jboss服务器到websphere服务器的迁移工作,我们刚开始的时候估计太过乐观,认为都是j2ee架构上的应用服务器,应该在1~2天内能够完成这个工作,但实际上,最终我们用了将近2周的时间才完成此工作。迁移过程中遇到了很多典型的问题,所以觉得有必要总结一下: 环境:jboss-tomcat 3.2.6 ,数据库oracle9i ,工作流部分到......
» 本期热门文章:

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