String类的toString()方法将自身返回为字符串。
import java.io.*;
public class Test {
public static void main(String args[]) {
String Str = new String("Welcome to Nhooo.com");
System.out.print("返回值:");
System.out.println(Str.toString());
}
}输出结果
返回值:Welcome to Nhooo.com