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);
}
}
When i compiled this code... i got this error.
Test.java:12: non-static method Receiving(int) cannot be referenced from a static context
Receiving (passing);
^
Now When i changed my method Receiving into static
, the output was....
The value of passing is: 3
Now how can i pass the value 3 into the method Receiving so that the output is 5 printed in the console.