Java零基础—方法执行过程中的内存分配

以如下代码为例:

 1 public class MethodTest01{
 2     public static void main(String[] args){
 3         int a = 10;
 4         int b = 20;
 5 
 6         int retValue = sumInt(a,b);
 7 
 8         System.out.println("retValue = " + retValue); 
 9 
10     }
11     
12     public static int sumInt(int i, int j){
13         int result = i + j;
14         int num = 3;
15         int retValue = divide(result,num);
16         return retValue; 
17     }
18     
19     public static int divide(int x,int y){
20         int z = x / y;
21         return z;
22     }
23 }

内存分析图如下:

世界旋转着我们的生命,一天一天的接近死亡。
原文地址:https://www.cnblogs.com/zhaozhg/p/14433500.html