您的位置: 首页 > IT文章 > Foreach语法 Foreach语法 分类: IT文章 • 2023-11-06 10:11:17 先看例子: Random rand = new Random(47); float f[] = new float[10]; for(int i = 0; i < 10; i++){ f[i] = rand.nextFloat(); } for(float x: f) { System.out.println(x); } foreach语法: for(float x: f) { System.out.println(x); }