本帖最后由 韩军博 于 2011-12-8 23:36 编辑
重写父类中的toString()方法就好了
class Employee
{
private String name;
private String id;
private double pay;
Employee(String name,String id)
{
this.name=name;
this.id=id;
}
public String toString()
{
return "name="+ name + "," + "id=" +id;
}
}
class EmployeeDemo
{
Employee employ=new Employee("zhangsan",“1001”);
employ.toString();
}
|