Java equals
boolean java.lang.Object.equals(Object obj)
Indicates whether some other
object is "equal to" this one.
The equals method implements an
equivalence relation on non-null object references:
It is reflexive: for
any non-null reference value x, x.equals(x) should return true.
It is
symmetric: for any non-null reference values x and y, x.equals(y) should return
true if and only if y.equals(x) returns true.
It is transitive: for any
non-null reference values x, y, and z, if x.equals(y) returns true and
y.equals(z) returns true, then x.equals(z) should return true.
It is
consistent: for any non-null reference values x and y, multiple invocations of
x.equals(y) consistently return true or consistently return false, provided no
information used in equals comparisons on the objects is modified.
For any
non-null reference value x, x.equals(null) should return false.
The equals
method for class Object implements the most discriminating possible equivalence
relation on objects; that is, for any non-null reference values x and y, this
method returns true if and only if x and y refer to the same object (x == y has
the value true).
Note that it is generally
necessary to override the hashCode method whenever this method is overridden, so
as to maintain the general contract for the hashCode method, which states that
equal objects must have equal hash codes
.
See
Also:
hashCode()
java.util.Hashtable
Parameters:
obj the
reference object with which to compare.
Returns:
true if this object is
the same as the obj argument; false otherwise.
相关文档:
Java 理论与实践: 描绘线程安全性
2007-12-15 00:10
——线程安全不是一个非真即假的命题
Brian Goetz (brian@quiotix.com), 首席顾问, Quiotix Corp
2003 年 11 月 15 日
7月份我们的并发专家 Brian Goetz 将 Hashtable 和 Vector 类描述为“有条件线程安全的”。一个类难道不是线程安全就是线程 ......
如果要使主窗口 居中一般使用下面的方法:
import javax.swing.*;
import java.awt.*;
public class ToCenter
{
public ToCenter(JFrame frame)
{
//---------------------------设置窗口居中---------------------------------------------------- ......
用Robot写Java代理
Rational Robot是通过录制用户操作进行功能,性能和兼容性测试的自动化测试工具。通过回放录制脚本进行功能和可靠性测试。本文主要介绍Rational Robot针对java程序和applets如何进行功能测试。
Rational Robot当前版本支持用以下类库开发的Java程序和applet程序:
lJava Foundation Classes(JFCs)
l ......
众所周知,在程序开发中,难免会遇到需要匹配、查找、替换、判断字符串的情况发生,而这些情况有时又比较复杂,如果用纯编码方式解决,往往会浪费程序员的时间及精力。因此,学习及使用正则表达式,便成了解决这一矛盾的主要手段。
大家都知道,正则表达式是一种可以用于模式匹配和替换的规范,一个正则表达式 ......
总结一:
Java IO的一般使用原则:
一、按数据来源(去向)分类:
1、是文件: FileInputStream, FileOutputStream, FileReader, FileWriter
2、是byte[]:ByteArrayInputStream, ByteArrayOutputStream
3、是Char[]: CharArrayReader, CharArrayWriter
4、是String: StringBufferInputStream, StringReader, StringW ......