Post

Call by value, Call by reference

โœ… Call by Value

  • when method is called, memory is allocated
  • Call by Value copys the value of variable as method parameter
  • local value(does not change value within the method)

case of java

java variable has the memory address where value is saved as value
orignial value is not changed
but has to allocate new memory space when variable is used,
๐Ÿ‘Ž๐Ÿป more memory usage

โœ… Call by Reference

  • when method is called, reference of value
  • if variable value is changed within the method, original value is changed
  • C/C+ can use call by reference
This post is licensed under CC BY 4.0 by the author.