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