- package cn.my;
- class Student1{
- private String name;
- private int age;
- private int higt;
-
- Student1(String name,int age,int higt){
- this.name = name;
- this.age = age;
- this.higt = higt;
- }
- public String toString(){
- return this.name+" "+this.age+" "+higt;
- }
- }
- public class Test4 {
- public static void main(String[] args) {
- // TODO 自动生成的方法存根
- Student1 s1 = new Student1("wangsan",12,156);
- System.out.println(s1);
- }
- }
- package cn.my;
- class dog{
-
- }
- public class Test5 {
-
- public static void main(String[] args) {
- // TODO 自动生成的方法存根
- dog d = new dog();
- System.out.println("d:="+d.toString());
- }
- }
复制代码
Test4结果:wangsan 12 156
Test5结果:d:=cn.my.dog@530cf2 |
|