Java Reference
In-Depth Information
LISTING 7.15
//********************************************************************
// ParameterTester.java Author: Lewis/Loftus
//
// Demonstrates the effects of passing various types of parameters.
//********************************************************************
public class ParameterTester
{
//-----------------------------------------------------------------
// Sets up three variables (one primitive and two objects) to
// serve as actual parameters to the changeValues method. Prints
// their values before and after calling the method.
//-----------------------------------------------------------------
public static void main (String[] args)
{
ParameterModifier modifier = new ParameterModifier();
int a1 = 111;
Num a2 = new Num (222);
Num a3 = new Num (333);
System.out.println ("Before calling changeValues:");
System.out.println ("a1\ta2\ta3");
System.out.println (a1 + "\t" + a2 + "\t" + a3 + "\n");
modifier.changeValues (a1, a2, a3);
System.out.println ("After calling changeValues:");
System.out.println ("a1\ta2\ta3");
System.out.println (a1 + "\t" + a2 + "\t" + a3 + "\n");
}
}
OUTPUT
Before calling changeValues
a1 a2 a3
111 222 333
Before changing the values:
f1 f2 f3
111 222 333
Search WWH ::




Custom Search