Call by value, Call by reference
โ Call by Value
- when method is called, memory is allocated
Call by Value
copys thevalue
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.