Something like this should do it:
android.util.Log.i("Instance", "This is: " + this);
By default, the toString
implementation of Object
will print the class type plus a hash code which can be considered somewhat equivalent to the this pointer in C++.
The toString
method for class Object
returns a string consisting of the name of the class of which the object is an instance, the at-sign character '@'
, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
If an object provides a different implementation of toString()
, like for instance String
does, then you can use the above canonical implementation of the base toString()
method to get the same results.