对象的内存分析

来源:互联网 发布:淘宝 清明上河图 编辑:程序博客网 时间:2024/05/17 00:17
对象的内存分析
  1. package cn.itcast.review;
  2. class Person{
  3. int id;
  4. String name;
  5. @Override
  6. public String toString() {
  7. return "编号:"+this.id+" 姓名:"+this.name;
  8. }
  9. }
  10. public class Demo6 {
  11. public static void main(String[] args) {
  12. Person p = new Person();
  13. p.id= 110;
  14. p.name = "狗娃";
  15. System.out.println(p);
  16. }
  17. }

0 0
原创粉丝点击