OnJava8-Examples/patterns/CommandPattern.java
Bruce Eckel ede3954d86 March 2021 Book Update
See notes in "Foreword to the Leanpub Edition"
2021-03-04 16:15:04 -07:00

27 lines
597 B
Java

// patterns/CommandPattern.java
// (c)2021 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
import java.util.*;
class Command {
public final String msg;
public Command(String msg) {
this.msg = msg;
}
}
public class CommandPattern {
public static void show(Command cmd) {
System.out.println(cmd.msg);
}
public static void main(String[] args) {
show(new Command("First Command"));
show(new Command("Second Command"));
}
}
/* Output:
First Command
Second Command
*/