Java toString() Method
The toString() method returns the object itself (which is already a string).
Syntax
public String toString()
Parameters
None
Return Value
The string itself.
Example
public class Test {
public static void main(String args[]) {
String Str = new String("WWW.example.com");
System.out.print("返回值 :" );
System.out.println( Str.toString() );
}
}
The output of the above program execution is:
返回值 :WWW.example.com
Other Extensions
Java String Class