java for each
int [] intArray = { 10, 20, 30, 40, 50 };
for( int value : intArray ) {
System.out.println( value );
}
3.86
7
//itemset contains variables of type <Data Type>
for(<Data Type> item : itemset) {
//loop
}
Thank you!
7
0
3.88
8
// for each loop in java example
import java.util.*;
public class ForEachLoopExample
{
public static void main(String[] args)
{
int[] numbers = {2, 4, 6, 8, 10};
// for each loop
for(int n : numbers)
{
System.out.println(n);
}
}
}
Thank you!
8
0
3.25
4
List<String> someList = new ArrayList<String>();
// add "monkey", "donkey", "skeleton key" to someList
for (String item : someList) {
System.out.println(item);
}
Thank you!
4
0
3.71
7
// definition eine Datenstruktur, hier ein Array mit 9 Werten
int[] array = new int[]{4, 8, 4, 2, 2, 1, 1, 5, 9};
// ForEach Schleife
for( int k: array )
{
System.out.println("k = "+k);
}
Thank you!
7
0
4.1
10
for (String name : names) {
System.out.println(name);
}
Thank you!
10
0
Are there any code examples left?
New code examples in category Java