untuk loop java
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
Clear Camel
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
int[] numbers =
{1,2,3,4,5,6,7,8,9,10};
for (int item : numbers) {
System.out.println(item);
}
//For Loop in Java
public class ForLoops
{
public static void main(String[] args)
{
for(int x = 1; x <= 100; x++)
{
//Each execution of the loop prints the current value of x
System.out.println(x);
}
}
}
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
class Main {
public static void main(String[] args) {
char[] vowels = {'a', 'e', 'i', 'o', 'u'};
// iterating through an array using a for loop
for (int i = 0; i < vowels.length; ++ i) {
System.out.println(vowels[i]);
}
}
}
public class ForLoop {
public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
// Will do this 5 times.
System.out.println("Iteration #: " + i);
}
}
}
for (Iterator<String> i = someIterable.iterator(); i.hasNext();) {
String item = i.next();
System.out.println(item);
}