提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
toString方法
public class TestToString { /* 时代Java公众号 - nowjava.com 提 供 */ public static void main(String[] args) { Employee emp = new Employee("A", "B"); System.out.println(emp.toString()); int x = 50; String s = new Integer(x).toString(); String s1 = "" + x; System.out.println(s); System.out.println(s1); } } class Employee { private String lastName; /*来自 时 代 J a v a 公 众 号 - N o w J a v a . c o m*/ private String firstName; public Employee(String lastName, String firstName) { this.lastName = lastName; this.firstName = firstName; } public String toString() { return