for 循环 foreach 循环输出练笔
来源:互联网 发布:李明linux百度云资源 编辑:程序博客网 时间:2024/05/20 02:56
旧:
public class HelloWorld {
public static void main(String[] args) {
// 定义一个整型数组,长度为10
int[] nums = new int [10];
//通过循环给数组赋值
for (int i = 0; i < nums.length; i++) {
// 产生10以内的随机数
int x = (int)(Math.random()*10);
nums[i] = x;// 为元素赋值
}
// 使用for循环输出数组中的元素
for ( int i=0;i<nums.length;i++ ) {
System.out.print(nums[i] + " ");
}
}
}
新:
public class HelloWorld {
public static void main(String[] args) {
// 定义一个整型数组,长度为10
int[] nums = new int [10];
//通过循环给数组赋值
for (int i = 0; i < nums.length; i++) {
// 产生10以内的随机数
int x = (int)(Math.random()*10);
nums[i] = x;// 为元素赋值
}
// 使用foreach循环输出数组中的元素
for (int num:nums ) {
System.out.print(num+ " ");
}
}
}
- for 循环 foreach 循环输出练笔
- for 循环,foreach循环
- 增强for循环 -- foreach循环
- for循环和foreach循环
- Foreach循环输出数组
- php二维数组的输出 for循环结合foreach
- c:forEach标签循环输出
- c:forEach 循环输出图片
- 增强的for循环--foreach循环
- for循环和foreach循环的区别?
- JSTL forEach标签(for循环)
- forEach 当 for循环使用
- foreach语句:增强for循环
- 高级for循环(foreach)
- for循环输出<九九乘法表>
- for循环输出<国际象棋>
- for 循环学习,输出
- for循环输出三角形
- hdu 5873 Football Games
- Android Rxjava的create的基本用法
- Zabbix Agent active主动模式监控
- 各种语言(php、python、shell、perl)中读一行或stdin
- iOS面试题集锦
- for 循环 foreach 循环输出练笔
- 扑克牌顺子
- iOS常用宏定义
- 使用google开源框架Exoplayer开发自定义播放器
- SAP R/3 中会计凭证和物料凭证的对应关系
- Vue.js结合vue-router和webpack编写单页路由项目
- 数据结构--链式队列
- Jquery 实现xml转json
- iOS 打开、关闭闪光灯