Java is equivalent to NET object. Equals(object,object)
•
Java
Yes NET System. Static methods defined in object
bool Equals(object a,object b);
This is a useful alternative to A. equals (b) where a may be null If both a and B are null, it also returns true
I can't find an equivalent method in the Java framework (my java is a little rusty now.) The simplest code I can say is:
(a==null && b==null) || (a!=null && a.Equals(b))
Does this method exist?
Note that I don't want to rely on any external framework I'm just curious if this simple method exists in the core Java class library
Solution
Currently, this does not exist in the core library, but it is one of the improvements added in Java 1.7
In Java 1.7, you can use objects equals(Object a,Object b). Before that, if you don't want to add an external dependency, I suggest you implement it yourself
source
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码