for each loop string java
for (char ch: "xyz".toCharArray()) {
System.out.println(ch);
}
4.25
10
// 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!
10
0
3.75
4
// 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!
4
0
3
1
String s = "xyz"
for (char ch: s.toCharArray()) {
System.out.println(ch);
}
Thank you!
1
0
Are there any code examples left?
New code examples in category Java