Java toString () method
toString () method returns the object itself (which is already a string).
grammar
public String toString()
parameter
no
return value
The string itself.
Examples
public class Test { public static void main(String args[]) { String Str = new String("WWW.w3big.com"); System.out.print("返回值 :" ); System.out.println( Str.toString() ); } }
The above program execution results:
返回值 :WWW.w3big.com