Controlling Execution(Thinking in Java)
1 import java.util.*;
2
3 public class ForeachDemo {
4 public static void main(String[] args)
5 {
6 float f[] = new float[10];
7 Random r = new Random(34);
8 for(int i=0; i<10; i++)
9 {
10 f[i] = r.nextFloat();
11 }
12
13 for(float fl : f)
14 {
15 System.out.println(fl);
16 }
17 }
18 }
2
3 public class ForeachDemo {
4 public static void main(String[] args)
5 {
6 float f[] = new float[10];
7 Random r = new Random(34);
8 for(int i=0; i<10; i++)
9 {
10 f[i] = r.nextFloat();
11 }
12
13 for(float fl : f)
14 {
15 System.out.println(fl);
16 }
17 }
18 }