toString() method which is use in android to know the states of java Object.
You can use log statements to figure out the state of any Java object. The easiest way to print out the contents of a Java object is to provide an implementation of the toString() method. The purpose of this method is to represent the whole object as a string, usually for debugging purposes.
Note: If you concatenate (with the “+” operator) a string with a Word object, then Java will implicitly call the toString() method on the object. That means, these two statements are equivalent:
Log.v("NumbersActivity", "Current word: " + word);
OR
Log.v("NumbersActivity", "Current word: " + word.toString());
Comments
Post a Comment