Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using `Objects.equals()` in Android

Tags:

java

android

I am trying to use the Objects.equals(obj a, obj b) method (link) in Android, but it seems Android does not have access to it. As far as I'm aware, this class was available in Java 1.7 and later. Is there any way to have access to this class in Android? Or is there an equivalent method that behaves the same way that I can use instead?

like image 508
Mike Baxter Avatar asked Dec 01 '22 19:12

Mike Baxter


1 Answers

Objects.equals() has the following source:

public static boolean equals(Object a, Object b) {
     return (a == b) || (a != null && a.equals(b));
 }
like image 184
Joetjah Avatar answered Dec 09 '22 07:12

Joetjah