Parameter Mystery
Category: Parameter Mystery
Author: Stuart Reges
Book Chapter: 3.1
Problem: Parameter Mystery
Consider the following program.
public class Mystery {
public static void main(String[] args) {
String foo = "buzz";
String sam = "sue";
String sue = "foo";
String bill = "hope";
String hope = "bill";
say(sam, sue, foo);
say(foo, "bill", sam);
say(hope, bill, sue);
say(bill, hope, sam);
say("sue", "hope", hope);
}
public static void say(String foo, String sam, String sue) {
System.out.println(sam + " wants " + sue + " to " + foo + ".");
}
}
List below the output produced by this program.
1) say(sam, sue, foo);
2) say(foo, "bill", sam);
3) say(hope, bill, sue);
4) say(bill, hope, sam);
5) say("sue", "hope", hope);