how to do a foreach loop in java code example Example: foreach java for (String name : names) { System.out.println(name); }