Java – call by value and call by reference2 min read

call by value in Java:

If a method is to be called by passing a parameter as value then it is said to be Call by Value. Here the changes made to the passed parameter do not affect on called method.

Example of call by value:

Output:

call by reference in Java:

If a method is to be called by passing a parameter(not the value) as a reference then it is said to be Call by Reference. Here the changes are made to the passed parameter effect on the called method.

Example of call by reference:

Output:


Type Conversion/Type Casting