How do we pass parameters by value in a Java method?



Passing Parameters by Value means calling a method with a parameter. Through this, the argument value is passed to the parameter.

Example

 public class SwappingExample { public static void swapFunction(int a, int b) { int c = a+b; System.out.println("Sum of the given numbers is ::"+c); } public static void main(String[] args) { int a = 30; int b = 45; swapFunction(a, b); } } 

Output

 Sum of the given numbers is ::75 
Updated on: 2019-07-30T22:30:20+05:30

318 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements