Skip to main content
13 events
when toggle format what by license comment
May 5, 2021 at 11:48 comment added Mark Rotteveel @saran3h That means that you haven't overridden equals(Object) in that class. See also Why this two simple objects are not equal?
May 5, 2021 at 8:54 comment added saran3h This is not helpful as it will always give false for 2 different objects having the exact same properties and values.
Jun 25, 2019 at 9:50 history edited Mark Rotteveel CC BY-SA 4.0
added 10 characters in body
Jun 25, 2019 at 9:50 comment added Mark Rotteveel @hyperpallium I link to the Javadoc, and any decent IDE will automatically suggest the import for you, but I'll add it.
Jun 25, 2019 at 9:04 comment added hyperpallium pls include package: java.util.Objects
Jan 9, 2018 at 19:46 comment added Neuron imho this should be the accepted answer. I don't want to reinvent the wheel in every single application I write
Oct 9, 2017 at 6:08 comment added Simon Baars @MarkRotteveel Ah, didn't read it too well. Thought you could just do object.equals(object) and the compiler fixed it into something that would prevent a NullPointerException.
Oct 8, 2017 at 15:46 comment added Mark Rotteveel @SimonBaars This isn't running a function on a null object, this is a static method that you pass two arguments, which can be null, or a reference to an object.
Dec 21, 2016 at 12:59 comment added Torsten Ojaperv I like this approach. No need to include some ApacheCommons library for things these days.
Jul 30, 2016 at 8:11 comment added Mark Rotteveel @averasko When you use Object.equals(Object) there is no compile time type check. The Objects.equals(Object, Object) works very much the same as a normal equals, and re inference/checks by IDE, those rules are heuristics that are also supported for Objects.equals(Object, Object) (eg IntelliJ IDEA 2016.2 has the same check for both the normal equals and the one from Objects).
Jul 30, 2016 at 1:51 comment added averasko this approach defers the type check until the runtime of the program. two consequences: it will be slower at runtime and IDE won't let you know if you by accident try to compare different types.
Apr 19, 2016 at 8:25 history edited Jens Piegsa CC BY-SA 3.0
added 110 characters in body
Jun 30, 2012 at 7:40 history answered Mark Rotteveel CC BY-SA 3.0