It seems that the method is instantiated in the heap area, but the heap area is the recognition of shared memory.

I feel that when Mr. A and Mr. B instantiate the same class and call the same method, the value changes. Is this a mistake?

public int tasizan (int a, int b) {
return a + b;

1, A calls method with tasizan (1,2)
↓ (Before Mr. A's return)
2, B calls the method with tasizan (3,4)

Isn't the above movement (a movement in which Mr. A's return value becomes "7") possible?

  • Answer # 1

    In the first place, even if you create an instance, there is no method there.
    Both instance methods and class methods are located in the memory area on the class side.
    This is because it is not necessary to prepare methods with exactly the same contents in the area of ​​each instance because only the field data is different for each instance.

    Then, the arguments such as a and b are placed in the stack area and the method is called.
    As you can see from the recursive call behavior, even if you call the same method in the middle of the method, the arguments and local variables of each method are independent, so
    It should not be rewritten without permission.