zoukankan      html  css  js  c++  java
  • 032_面向对象_05_程序执行过程的内存分析_02

    一、实例代码  

    package edu.aeon.test;
    /**
     * [说明]计算机类
     * @author aeon
     */
    public class Computer {
        /**计算机品牌*/
        public String brand;
        /**计算机cpu速度*/
        public int cpuSpeed;
    }
    package edu.aeon.test;
    /**
     * [说明]学生类
     * @author aeon
     * 类包括静态的属性和动态行为
     */
    public class Student {
        /**学生证号*/
        private  int stuId;
        /**学生姓名*/
        private String stuName;
        /**学生性别 0(false)-女  1(true)-男*/
        private boolean sex;
        /**学生电脑*/
        private Computer computer;
    /**
     * 动态行为:学习    
     */
     public void stard(){
        System.out.println(stuName+"正在学习!"); 
     }
     public static void main(String[] args) {
        /**创建学生对象(实例)*/
        Student student=new Student();
        System.out.println("==================默认初始化==================");
        System.out.println("学生证号:"+student.stuId);
        System.out.println("学生姓名:"+student.stuName);
        System.out.println("学生性别:"+student.sex);
        student.stard();
        System.out.println("==================程序初始化==================");
        student.stuId=10010;
        student.stuName="张三";
        student.sex=true;
        System.out.println("学生证号:"+student.stuId);
        System.out.println("学生姓名:"+student.stuName);
        System.out.println("学生性别:"+(student.sex==true?"男":"女"));
        student.stard();
        
        
        Computer computer=new Computer();
        computer.brand="联想";
        student.computer=computer;
        System.out.println(student.computer.brand);
     }
    }

    二、内存分析图

      

    如有任何疑问可联系邮箱: 给我发邮件、或直接联系QQ:1584875179 || 点返回首页

  • 相关阅读:
    git代码冲突
    Centos Git1.7.1升级到Git2.2.1
    linux指定某非root用户执行开机启动项的方法(gogs git)
    kvm增加硬盘挂载
    git分支管理策略
    mac命令行配置网络
    svn稀疏目录--通过设置工作目录的深度(depth)实现目录树的部分签出
    svn update解决冲突
    rocketmq单机搭建
    MongoDB数据库未授权访问漏洞及加固
  • 原文地址:https://www.cnblogs.com/aeon/p/9951570.html
Copyright © 2011-2022 走看看