Pass by value or Pass by reference in Java?
<p>I read many articles and all says Java is pass by value. But i still don't construe the difference between pass by value and reference. I wrote a sample program and it executes like this.. </p>

<pre><code>public class PassByValue {

   private int a;
   private int b;

   public PassByValue(int a, int b) {
    this.a = a;
    this.b = b;
   }

   public static int mul(int a, int b) {

       int z = a * b;
       System.out.println("The Value of Z inside mul: " + z);
       return z;

   }

   public static void main(String args[]) {

    int z = 100;

        int x = 40;
        int y = 20;

    mul(x,y);

    PassByValue pass = new PassByValue(x,y);
    mul(pass.a,pass.b);

        System.out.println("The Value of Z" + z);

   }

}
</code></pre>

<p>Execution </p>

<pre><code>800
800 and 
100
</code></pre>

<p>Can anyone explain me these questions... </p>

<ol>
<li>What is Pass By Value means... </li>
</ol>

<p>Answer: Its just passing the numbers or value stored in the variable to a function. Am i right or wrong.</p>

<ol>
<li>How do you say Java is Pass By Value?</li>
<li>Why is Java is Pass By Value and not by reference?</li>
<li>Does the above program Tries shows an example of Pass by value and Reference... but still does things via Pass by Value only... I wrote that program.</li>
</ol>
