发现个好东西: 一个免费短链生成项目:“ https://www.isok.co”一个可以生成所有短链的服务,isok.co的这个含义能覆盖所有短链含义isok, 我试过了很不错,都可以试试
覆写前:
/** * Created by xabcd on 2019/2/16. */ class total_print extends Object{ String name = "张三:" ; int age = 25; }
/** * Created by xabcd on 2019/2/16. */ public class test_print { public static void main(String args[]) { total_print p = new total_print(); System.out.println(p); } } 结果: total_print@4554617c 覆写后:
/** * Created by xabcd on 2019/2/16. */ class total_print extends Object{ String name = "张三:" ; int age = 25; public String toString() { return"我是:"+this.name+",今年:"+this.age+"岁"; } }
/**
* Created by xabcd on 2019/2/16.
*/
public class test_print
{
public static void main(String args[])
{
total_print p = new total_print();
//此时本行相当于 System.out.println(p.toString());
System.out.println(p);
}
}
结果: 我是:张三:,今年:25岁