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
What is permgen or permanent generation?
What are the sequence of steps to write pub or sub model kind of application?
What is a modular application?
What is meant by method chaining?
Why are component architectures useful?
What is Stream Tokenizer?
how do you Handle Front End Application data against DB with example?
What is chat area? Explain.
how to use debug in my elipse to solve problems that exist in my project
Difference between DurableSubscription and non- DurableSubscription?
what is handle?
What is the purpose of the wait() method?
What is message driven beam?
How are commas used in the intialization and iteration parts of a for statement?
Why use a datasource when you can directly specify a connection details?