what will be the implementation for
public int hashCode()
{
}
method in singleton class? Please do provide me the implementation
Since there's only one object, you don't have to worry about making other, equal, objects have the same hashCode. So you can just use System.identityHashCode (i.e. the default).
If it's a singleton, you don't need to provide an implementation, as it will be the same object instance wherever it's used. The default (System.identityHashCode(obj)) will be sufficient, or even just a constant number (eg 5)
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