Java Pass Method as Parameter

Edit: as of Java 8, lambda expressions are a nice solution as other answers have pointed out. The answer below was written for Java 7 and earlier… Take a look at the command pattern. Edit: as Pete Kirkham points out, there’s another way of doing this using a Visitor. The visitor approach is a little more involved – your nodes all need to be … Read more