-
Notifications
You must be signed in to change notification settings - Fork 0
santhoshArun/Pass-by-value
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
C is call by value and Java is calling reference as a value.
Here we have used a swap function that swaps the value given to it and we are passing two things, one is a normal variable and the other instance of the class(reference type).
The normal variable remains unaffected and we don't need this here.
First we use setval() function that sets the value of the current instance with the help of reference, here it is using the reference and changing the value and not changing the reference variable itself.
So if we tried to change the reference variable like d = new demo(30); the variable remains unaffected.
Thus it is proved that we can't change the referece variable, we can use the reference or instance to alter the other values.
So java is call by value or calling reference as a value.
About
java is a pure pass by value explanation
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published