Parameters are Passed by value or reference in Java

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.