数组
来源:互联网 发布:小米平板2 ubuntu 编辑:程序博客网 时间:2024/06/14 13:33
public class ArrayTest {public static void main(String[] args) {//arrayOne();arrayTwo();}public static void arrayOne(){/* * 一维数组 * 数组类型 数据名[] = new 数组类型[个数]; * *///动态方法int test1[] = new int[2];test1[0] = 1;test1[1] = 3;for(int i:test1){System.out.print(i +" ");}System.out.println();//静态方法int test11[] = {0,1,2,4,5};for(int i:test11){System.out.print(i +" ");}}public static void arrayTwo(){/* * 二维数组 * 数组类型 数据名[][] = new 数组类型[个数][]; * *///动态方法String test1[][] = new String[2][2];//2*2=4test1[0][0] = "00";test1[0][1] = "01";test1[1][0] = "10";test1[1][1] = "11";for(int i=0;i<test1.length;i++){for(int j=0;j<test1[i].length;j++){System.out.print(test1[i][j]+"\t");}System.out.println();}System.out.println();//静态方法int test2[][] ={{1,2},{2,2,4},{1,2,1,4}};//2+5+4=11for(int i=0;i<test2.length;i++){for(int j=0;j<test2[i].length;j++){System.out.print(test2[i][j]+"\t");}System.out.println();}}}
0 0
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- Config程序配置文件操作实践进阶之ConfigurationSectionGroup
- Html文档解析器 HtmlCleaner 编辑
- 学习笔记之三 获取系统时间的方法汇总
- 当在struts2中出现了404
- poj2021 字符串处理 BFS
- 数组
- 【网络基础】OSI TCP/IP体系结构
- MinGW MinGW-w64 TDM-GCC等工具链之间的区别与联系
- table行随鼠标变色
- Ubuntu下架设FTP服务器
- 板子启动NFS服务
- POJ2288:Islands and Bridges(状态压缩)
- JavaScript调用函数不需要对象
- sandglass(沙漏)——一个让人解脱的python时间处理库