Java toString() Method
The toString() method returns this object itself (it 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.RUNOOB.COM");
System.out.print("返回值 :" );
System.out.println( Str.toString() );
}
}
The execution result of the above program is:
返回值 :WWW.RUNOOB.COM
Java String class