list foreach java 8 code example Example: java foreach list list.forEach((MyType myObject) -> {/* code */});