zoukankan      html  css  js  c++  java
  • 代码分析系列 内存执行过程

    1、内存执行过程:(六:01:32:08-->)

    package primary;

    public class Main {
        public static void main(String args[]){
            Main m= new Main();
            int day = 15;
            Birthday b1 = new Birthday(27,11,1988);
            Birthday b2 = new Birthday(23,04,2013);
            m.change1(day);
            m.change2(b1);
            m.change3(b2);    
            b1.Display();
            b2.Display();
            }
        void change1(int num){
            num = 123;
        }
        void change2(Birthday b){
            b = new Birthday(04,01,1989);
        }
        void change3(Birthday b){
            b.setDay(26);b.setMonth(01);b.setYear(2015);
            
        }
    }

    class Birthday{
        int day;int month;int year;
        Birthday(int _day, int _month, int _year){
            day = _day;month = _month;year = _year;
        }
        void Display(){
            System.out.println("Birthday is:"+year+"-"+month+"-"+day);
        }
        public int getDay() {
            return day;
        }

        public void setDay(int day) {
            this.day = day;
        }

        public int getMonth() {
            return month;
        }

        public void setMonth(int month) {
            this.month = month;
        }

        public int getYear() {
            return year;
        }

        public void setYear(int year) {
            this.year = year;
        }
        
    }

    输出:

    Birthday is:1988-11-27
    Birthday is:2015-1-26

    2、涉及知识:

      栈内存和堆内存;引用传递和值传递;栈变量用完就释放,堆内存若干时间后会被GC回收。

      

  • 相关阅读:
    MySQL 存储过程实例
    [MySQL优化] -- 如何了解SQL的执行频率
    [MySQL优化] -- 如何定位效率较低的SQL
    [MySQL优化] -- 如何查找SQL效率地下的原因
    [MySQL优化] -- 如何使用SQL Profiler 性能分析器
    2020.10.09软件更新公告
    2020.04.12软件更新公告
    2020.04.11软件更新公告
    2020.02.21软件更新公告
    程序员调用MODI的正确姿势
  • 原文地址:https://www.cnblogs.com/RunForLove/p/4337388.html
Copyright © 2011-2022 走看看