[Command mode] encapsulates a request as an object to parameterize other objects using different requests, queues, or logs. The command mode also supports unrecoverable operations. 1. Define the command interface [html] package com. pattern. command; public interface Command {public void execute () ;}2, interface implementation class [html] package com. pattern. command; public class LightOnCommand implements Command {Light light Light; public LightOnCommand (light Light light) {this. light = light;}/*** @ see com. pattern. command. command # execute () */@ Override public void execute () {light. on () ;}} 3, the specific executor of the command [html] package com.pattern.com Mand; public class Light {public void on () {System. out. println ("turn on the light! ") ;}} 4, controller class [html] package com. pattern. command; public class SimpleRemoteControl {Command slot; public SimpleRemoteControl () {} public void setCommand (Command command) {slot = command;} public void buttonWasPressed () {slot.exe cute () ;}} 5, test class [html] package com. pattern. command; public class RemoteControlTest {public static void main (String [] args) {SimpleRemoteControl remote = new SimpleRemote Control (); Light light = new Light (); LightOnCommand lightOn = new LightOnCommand (light); remote. setCommand (lightOn); remote. buttonWasPressed () ;}} output: turn on the light!