Java toString() 方法
toString() 方法返回此對象本身(它已經是一個字串)。
語法
public String toString()
參數
無
返回值
字串本身。
實例
public class Test { public static void main(String args[]) { String Str = new String("WWW.xuhuhu.com"); System.out.print("返回值 :" ); System.out.println( Str.toString() ); } }
以上程式執行結果為:
返回值 :WWW.xuhuhu.com