OnJava8-Examples/streams/Machine2.java
Bruce Eckel bc0026c3e1 Radically reorganized
Plus many new examples in "streams" chapter.
2015-11-11 20:20:04 -08:00

20 lines
370 B
Java

// streams/Machine2.java
import java.util.*;
public class Machine2 {
public static void main(String[] args) {
Arrays.stream(new Operation[] {
() -> Operation.show("Bing"),
() -> Operation.show("Crack"),
() -> Operation.show("Twist"),
() -> Operation.show("Pop")
}).forEach(Operation::execute);
}
}
/* Output:
Bing
Crack
Twist
Pop
*/