JAVA新手重写toString方法遇到的问题
class Person
{
String name;
int age;
Person(String name,int age)
{
this.name=name;
this.age=age;
}
public String toSting()
{
return "我是:"+this.name+",今年:"+this.age+"岁";
}
}
class Demo
{
public static void main(String[] args)
{
Person p=new Person("zhangsan",25);
System.out.println(p.toString());
}
}