- 1、本文档共28页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ch07 - 多维数组
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 Chapter 7 Multidimensional Arrays Motivations Thus far, you have used one-dimensional arrays to model linear collections of elements. You can use a two-dimensional array to represent a matrix or a table. For example, the following table that describes the distances between the cities can be represented using a two-dimensional array. Objectives To give examples of representing data using two-dimensional arrays (§7.1). To declare variables for two-dimensional arrays, create arrays, and access array elements in a two-dimensional array using row and column indexes (§7.2). To program common operations for two-dimensional arrays (displaying arrays, summing all elements, finding min and max elements, and random shuffling) (§7.3). To pass two-dimensional arrays to methods (§7.4). To write a program for grading multiple-choice questions using two-dimensional arrays (§7.5). To solve the closest-pair problem using two-dimensional arrays (§7.6). To check a Sudoku solution using two-dimensional arrays (§7.7). To use multidimensional arrays (§7.8). Declare/Create Two-dimensional Arrays // Declare array ref var dataType[][] refVar; // Create array and assign its reference to variable refVar = new dataType[10][10]; // Combine declaration and creation in one statement dataType[][] refVar = new dataType[10][10]; // Alternative syntax dataType refVar[][] = new dataType[10][10]; Declaring Variables of Two-dimensional Arrays and Creating Two-dimensional Arrays int[][] matrix = new int[10][10]; or int matrix[][] = new int[10][10]; matrix[0][0] = 3; for (int i = 0; i matrix.length; i++) for (int j = 0; j matrix[i].length; j++) matrix[i][j] = (int)(Math.random() * 1000); double[][] x; Two-dimensional Array Illustration Declaring, Creating, and Initializing Using Shorthand Notations You can also use an array initializer to declare, create and initial
您可能关注的文档
- 上海悦动电子科技有限公司.pdf
- 三种纳米材料C_70_C_60_Cl_6和C_60_Ph_6引起细胞自噬的现象.pdf
- 严蔚敏《数据结构(c 语言版)习题集》第8章动态存储管理.pdf
- 不同剪力连接程度预应力钢混凝土组合连续梁的试验研究.pdf
- 中国- 东盟自由贸易区: 经验、问题 及对两岸签订 E CF A 的启示.pdf
- 东诚教育集团二级建造师市政管理考试重点—200.pdf
- 一级建造师市政实务真题09-13.doc
- 三种盐胁迫对互花米草和芦苇光合作用的影响_胡楚琦_刘金珂_王天弘_王文琳_卢山_.pdf
- 中国大型民营企业的绩效变化及其决定因素(赵世勇).pdf091116.pdf
- 上海自由贸易试验区建立对中国经贸发展的影响.pdf
文档评论(0)