1

  1. public class Shape{
  2. public void test(Shape a,Shape b) {
  3. int s = 1;
  4. }
  5. public static void main(String[] args){
  6. // 运行至此处
  7. Shape m = new Shape();
  8. Shape n = new Shape();
  9. test(m,n);
  10. }
  11. }

Java引用过程 - 图1

2

  1. public class Shape{
  2. public void test(Shape a,Shape b) {
  3. int s = 1;
  4. }
  5. public static void main(String[] args){
  6. Shape m = new Shape();
  7. // 运行至此处
  8. Shape n = new Shape();
  9. test(m,n);
  10. }
  11. }

Java引用过程 - 图2

3

  1. public class Shape{
  2. public void test(Shape a,Shape b) {
  3. int s = 1;
  4. }
  5. public static void main(String[] args){
  6. Shape m = new Shape();
  7. Shape n = new Shape();
  8. // 运行至此处
  9. test(m,n);
  10. }
  11. }

Java引用过程 - 图3

4

  1. public class Shape{
  2. public void test(Shape a,Shape b) {
  3. // 运行至此处
  4. int s = 1;
  5. }
  6. public static void main(String[] args){
  7. Shape m = new Shape();
  8. Shape n = new Shape();
  9. test(m,n);
  10. }
  11. }

Java引用过程 - 图4

5

  1. public class Shape{
  2. public void test(Shape a,Shape b) {
  3. int s = 1;
  4. }
  5. public static void main(String[] args){
  6. Shape m = new Shape();
  7. Shape n = new Shape();
  8. test(m,n);
  9. // 运行至此处,test方法相关退栈
  10. }
  11. }

Java引用过程 - 图5