Parameters are Passed by value or reference in Java

Please follow and like us:
11

This is sometime confusing whether in java it is “passed by Value or Reference”. Here is the answer to this confusing question.

In Java parameters are “passed by value”.

  1. In case of Primitive Data Types, the data value of actual parameter is passed.
  2. If actual parameter is a reference to an Object (Class,Enum or Array object instance), then the reference value is passed, not the object itself. Means changes made to formal parameters will be reflected in the actual parameters.

Anuj Aneja did his Graduation from a reputed college in India YMCA Institute of Engineering. He is having more than 7 years of experience in various domains like: HealthCare, Telecom, Financial Sector. Till now, He has worked on various technologies like: Java, Python, Hadoop Ecosystem and Spark. He has vast experience in designing both Web application as well as High performance Scalable applications. He has also worked on both SQL and NoSQL database management systems like: Mysql, Oracle, Mongodb.

Please follow and like us:
11

Leave a Reply

Your email address will not be published. Required fields are marked *