Does Java pass arguments by value or reference?
Answer Posted / mr.h
In Java no matter what type of argument you
pass the corresponding parameter (primitive variable or object reference) will get a copy of that data, which is
exactly how pass-by-value (i.e. copy-by-value) work.
In Java, if a calling method passes a reference of an object as an argument to the called method then the passedin
reference gets copied first and then passed to the called method. Both the original reference that was
passed-in and the copied reference will be pointing to the same object. So no matter which reference you use, you
will be always modifying the same original object, which is how the pass-by-reference works as well
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Are we allowed to change the transaction isolation property in middle of a transaction?
Can constructors be synchronized in java?
What is bean? Where can it be used?
Is the infobus client side only?
Can you give me a simple example of using the requiredif validator rule?
What are the different algorithms used for clustering?
What is the difference between a menuitem and a checkboxmenuitem?
What is the diffrence between a local-tx-datasource and a xa-datasource?
In inglish: How to convert jar to exe files? Em português: Como converter arquivos .jar para .exe?
What is a class loader?
what are the activation groupworks?
How a component can be placed on Windows?
Is “abc” a primitive value?
Is the ternary operator written x : y ? Z or x ? Y : z ?
What is the relation between the infobus and rmi?