What is the function of toString in here?
what is the need for toString
谁能解释一下 toString 在这里应该做什么。我是java新手,学习了很多新东西
public class Employee
{
private String name;
private String address;
private int number;
public Employee(String name, String address, int number)
{
System.out.println("Constructing an Employee");
this.name = name;
this.address = address;
this.number = number;
}
public String toString() //what is this function doing
{
return name + " " + address + " " + number;
}