JAVA中toString方法的作用
public class Orc
{
public static class A
{
public String toString()
{
return "this is A";
}
}
public static void main(String[] args)
{
A obj = new A();
System.out.println(obj);
}
}
如果某个方法里面有如下句子:
A obj=new A();
System.out.println(obj);
会得到输出:this is A