implement foreach to make an action in collections java code example Example: inline foreach java names.forEach(name -> System.out.println(name));