title: How to use Pass by Value in Java
body: <pre><code>public class Test {
  
          public void Receiving (int var)
          {
            var = var + 2;
          }
  
          public static void main(String [] args)
          {
            int passing = 3;
  
            Receiving (passing);
  
            System.out.println("The value of passing is: " +passing);
          }    
      }
  </code></pre>
  
  <p>When i compiled this code... i got this error. </p>
  
  <pre><code>Test.java:12: non-static method Receiving(int) cannot be referenced from a static context
    Receiving (passing);
    ^
  </code></pre>
  
  <p>Now When i changed my method Receiving into <code>static</code>, the output was.... </p>
  
  <pre><code>The value of passing is: 3
  </code></pre>
  
  <p>Now how can i pass the value 3 into the method Receiving so that the output is 5 printed in the console. </p>