Object类中toString方法
2014-01-08 11:16
609 查看
/*public class ToStringMethod { String str; int age; public static void main(String args[]) { ToStringMethod train=new ToStringMethod(); System.out.println(train); } }*/ public class ToStringMethod { String str; int age; public String toString() { return ("My name is "+this.str); } public static void main(String args[]) { ToStringMethod train=new ToStringMethod(); System.out.println(train); } }直接打印引用时。会调用其toString()方法,这一点必须注意!
相关文章推荐
- object类的toString()与equals()方法
- Object类----toString方法
- 【Java基础之Object类(一)】Java中Object类中的所有方法(toString、equals、hashCode、clone、finalize、wait和notify等)详解(转载)
- 常见对象_Object类的概述、hashCode()方法、getClass()方法、toString()方法
- Object类中的toString和equal方法
- Java中Object类的方法(toString方法和equals方法)
- 【Java基础之Object类(一)】Java中Object类中的所有方法(toString、equals、hashCode、clone、finalize、wait和notify等)详解
- 有关java object类的toString方法
- Object类----toString方法
- 浅谈Object类的toString方法
- 如何覆盖Object类中的equals(),hashCode(),toString()方法
- Object类中的toString(),equals(), hashCode()方法之间的关系
- Object类及toString方法介绍
- Object类的toString方法
- Object类----toString方法
- override重写 object类的ToString()方法。
- 黑马程序员:Object类和equals、toString方法介绍
- 这样覆写Object类的toString方法对吗
- Object类中的toString()方法
- Object类----toString方法