string foreach java 8 code example Example: inline foreach java names.forEach(name -> System.out.println(name));