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());
}
}
无论怎样修改进行测试最后输出的都是hashCode值?求解释啊!!
java hashcode string
------解决方案--------------------
看看你写的什么toSting