
Untitled
By: a guest on
May 9th, 2012 | syntax:
None | size: 0.48 KB | hits: 15 | expires: Never
public class PassPrimitiveByValue
{
static int x = 3;
// change parameter in passMethod()
public static void passMethod(int p)
{
p = 10;
System.out.println("Right now pass method is invoked and its parameter's value is: " + p);
}
public static void main(String[] args)
{
//invoke passMethod() with x as argument
passMethod(x);
// print x to see if its value has changed
System.out.println("After invoking passMethod, x = " + x);
}
}