Java Foundation Content
The ToString method We use everywhere, is a very important little knowledge, here about:
We look at the API documentation to see a detailed description of the Java.lang.Object class's ToString Method:
Tostring
Public String toString ()
Returns a string representation the object. In general, the ToString method is returns a string that "textually represents" this object. The result should being a concise but informative representation that are easy for a person to read. It is recommended the all subclasses override this method.
The ToString method for class Object returns a string consisting of the name of the class of which the Object being an Instan CE, the at-sign character ' @ ', and the unsigned hexadecimal representation of the hash code of the object. In the other words, this is returns a string equal to the value of:
GetClass (). GetName () + ' @ ' + integer.tohexstring (hashcode ())
Returns:
A string representation the object.
We probably translate:
Returns a string that can represent this object. In general, the ToString method returns the "text expression" of this object. The return result is concise but not an informative expression that is easy for people to read. It is recommended that you override this method when using subclasses.
For the class object, the ToString method return value is made up of the class name of the owning class, an "@" symbol, and an unsigned hexadecimal expression of the object's hash code. In other words, the string returned by this method is equivalent to the value returned by the following method:
GetClass (). GetName () + ' @ ' + integer.tohexstring (hashcode ())
Return:
The string expression of this object
Let's look at the ToString method in the Java.lang.String class to see if it's the same.
Tostring
Public String toString ()
This object (which are already a string!) is itself returned.
Specified by:
ToString in Interface charsequence
Overrides:
ToString in class Object
Returns:
The string itself.
Let's just translate it:
The object itself (which is already a string) is the return value
Description
The ToString method in the Charsequence interface
Rewrite:
To rewrite the ToString method in object
Return:
string of its own