Tuesday, 7 March 2017

reference - Pass by value in Java





Possible Duplicates:
Does Java pass by reference?
Is Java pass by reference?







Hey,



Is it true that Java passes everything by value, and we can't pass something by reference ?



Thanks.


Answer




Good God, it can't be asked again. Java is pass by value - always, in all cases. That's it.



Here's a reference that quotes James Gosling, who should be authoritative enough for anyone:




From the authors of Java: "There is
exactly one parameter passing mode in
Java - pass by value - and that helps
keep things simple." The Java
Programming Language, 2nd ed. by Ken

Arnold and James Gosling, section
2.6.1, page 40, 3rd paragraph.



No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...