Question: In java all methods are pass by value.But today i learnt that constructors are pass by reference.

```
// Attack the internals of a Period instance
Date start = new Date();
Date end = new Date();
Period p = new Period(start, end);
end.setYear(78);  // Modifies internals of p!

```

This works and is able to edit the private fields.

What is the reason of this decision? or am i missing something?

Answer: 
the mechanism is same for both constructor and method. From the [doc](http://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html)

> 
> Reference data type parameters, such as objects, are also passed into
>  methods by value. This means that when the method returns, the
>  passed-in reference still references the same object as before.
>  However, the values of the object's fields can be changed in the
>  method, if they have the proper access level
> 
> 
>
You are dealing with only references,not objects.

The classic definition of pass by value.

*The value of a reference variable is an "address" in Java. When you pass a reference variable to a method, a new reference variable is placed on the stack and a copy of the passed reference variable's value is used to initialize the new local **reference varaible's value, just like any primitive type.***

**NOTE**: While you can think of the reference as a memory address, it's not. The underlying mechanism makes it act logically as if it were though.

**SHORT VERSION**: references are simple variables just like the other primitive types for purposes of passing arguments to methods. What you can do with them once passed is obviously different.