本文介绍了在Java 7的equals()和deepEquals()上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方法描述如下:

我)建议,如果对象保持引用的每个对象也使用equals()方法相等,则它们之间的深度相等。并且它们引用的每个对象也相等。 ..



所以.. 等式是通过使用第一个参数的equals方法确定的。



.equals()有何不同?假设我们在哪里恰当地描述了相等,那么对象等于另一个对象就是该对象的每个字段也都等于它。 Objects.deepEquals() Objects.equals()之间的区别?

解决方案

如果 deepEquals 方法的至少一个参数不是数组,则 Objects.deepEquals Objects.equals 相同。


Method description says:

Which (to me) suggests that Objects are deeply equal if every object they maintain references to are also equal using the equals() method. And every objects they have a reference to are also equal. And ..

So .. equality is determined by using the equals method of the first argument.

How is this different from .equals()? Assuming that we describe equals appropriately where, objects is equal to another object is every field of the object is equal to it as well.

Can you please provide an example illustrating the difference between Objects.deepEquals() and Objects.equals()?

解决方案

If at least one of the arguments of deepEquals method is not an array, then Objects.deepEquals and Objects.equals are same.

这篇关于在Java 7的equals()和deepEquals()上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 00:56