-
December 7th, 2018, 11:09 PM
#1
pass by value and pass by reference in Java?
What is the difference between pass by value and pass by reference in Java?
-
December 8th, 2018, 01:04 AM
#2
Re: pass by value and pass by reference in Java?
Try searching in bing or google for "What is the difference between pass by value and pass by reference in Java?".
-
December 8th, 2018, 01:28 PM
#3
Re: pass by value and pass by reference in Java?
There are no references in java
Norm
-
December 9th, 2018, 12:47 AM
#4
Re: pass by value and pass by reference in Java?
Originally Posted by kadammanali987
What is the difference between pass by value and pass by reference in Java?
The parameter passing mechanism in Java is always by_value. The by_reference passing mechanism doesn't exist in Java. It means whatever you pass (a primitive or a reference) to a method it will be copied before it is available in the method.
It's important to understand that objects are always represented/handled indirectly by so called references in Java. A reference can be thought of as a "pointer" to an object. Therefore you could claim that "in Java an object is passed by its reference" but that doesn't mean the passing mechanism is by_reference (in the computer science sense of the term). So a reference is passed indeed but it is by_value, hence the confusion.
Last edited by wolle; December 9th, 2018 at 07:09 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|