I need to make equals function for MyClas.
public class MyClass
{
boolean equals(Object value)
{
if (... value is type of MyCLass ...)
{
return= ... check conditions...;
} else return false;
}
}
For this purpose I need to know if value of Object is type of MyClass. How to make it?
In order to check if value
is of type MyClass
use:
if( value instanceof MyClass)
instanceof
operator is used to determine that. It's infix, so use it like so...
(value instanceof MyClass)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With