Java toString() メソッド
toString() メソッドはこのオブジェクト自体を返します(これはすでに文字列です)。
構文
public String toString()
パラメータ
无
戻り値
文字列自体。
例
public class Test {
public static void main(String args[]) {
String Str = new String("WWW.example.com");
System.out.print("返回值 :" );
System.out.println( Str.toString() );
}
}
上記のプログラムの実行結果は次のとおりです。
返回值 :WWW.example.com
その他の拡張