how to for each code example
Example 1: java for each loop
int[] array = new int[]{4, 8, 4, 2, 2, 1, 1, 5, 9};
for( int k: array )
{
System.out.println("k = "+k);
}
Example 2: for each javascript
let numbers = ['one', 'two', 'three', 'four'];
numbers.forEach((num) => {
console.log(num);
});
Example 3: java foreach
List<String> someList = new ArrayList<String>();
for (String item : someList) {
System.out.println(item);
}
Example 4: for each
const array1 = ['a', 'b', 'c'];
array1.forEach(element => console.log(element));