大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第二篇 面向对象程序设计 第7章 数组和向量

第7章数组和向量 G理解数组的概念 学习目 学习使用数组 a熟悉排序和查找算法 a学会如何使用多维数组 熟悉数字包装类和他们的子类 G了解如何使用命令行参数 际-使用 Vector类
第7章 数组和向量 )理解数组的概念 )学习使用数组 )熟悉排序和查找算法 )学会如何使用多维数组 )熟悉数字包装类和他们的子类 )了解如何使用命令行参数 )使用Vector类

Introducing Arrays 数组是相同类型的数据按顺序组成mN0 的一种复合数据类型,通过数组名吗以叫 和下标,可以使用数组中的数据。 myList[3 下标从0开始。数组是所有编程语m4 言中常用的数据结构。 myList[5] myList[6] myList[7 myList[8 doub1e类型的10个数组元素 myList[9] doublel my list= new double 10
Introducing Arrays myLis t[0] myLis t[1] myLis t[2] myLis t[3] myLis t[4] myLis t[5] myLis t[6] myLis t[7] myLis t[8] myLis t[9] 数组是相同类型的数据按顺序组成 数组是相同类型的数据按顺序组成 的一种复合数据类型,通过数组名 的一种复合数据类型,通过数组名 和下标,可以使用数组中的数据。 和下标,可以使用数组中的数据。 下标从 0开始。数组是所有编程语 开始。数组是所有编程语 言中常用的数据结构。 言中常用的数据结构。 double 类型的10个数组元素 : double[] myList = new double[10]

Declaring Arrays datatype[] arraynamei Example: int[] mylisti datatype arrayname[] Example: int myList[li
Declaring Arrays ) datatype[] arrayname; Example: int[] myList; ) datatype arrayname[]; Example: int myList[];

Creating arrays arrayName new datatype[arraysizeli Example: myList new double[10]
Creating Arrays arrayName = new datatype[arraySize]; Example: myList = new double[10];

Declaring and Creating in One step datatype [] arrayname =new datatype [arraysize]i double [ myList new double [10]i datatype arrayname[] new datatype [arraysizeli double myList[] new double [10]
Declaring and Creating in One Step ) datatype[] arrayname = new datatype[arraySize]; double[] myList = new double[10]; ) datatype arrayname[] = new datatype[arraySize]; double myList[] = new double[10];

Initializing arrays Using a loop for (int i=0; i< myList. length; i++) myList[i]=(double)i G Declaring, creating initializing in one step doub1e[] myList={1.9,2.9,3.4,3.5};
Initializing Arrays ) Using a loop: for (int i = 0; i < myList.length; i++) myList[i] = (double)i; ) Declaring, creating, initializing in one step: double[] myList = {1.9, 2.9, 3.4, 3.5};

Example 7.1 assigning grades Objective: read student scores(int) from the keyboard, get the best score, and then assign grades based on the following scheme Grade is a if score is > best-10 Assign Grade Grade is b if score is > best-20 Run Grade is c if score is >s best-30 Grade is d if score is > best- 40 Grade is f otherwise
Example 7.1 Assigning Grades ) Objective: read student scores (int) from the keyboard, get the best score, and then assign grades based on the following scheme: – Grade is A if score is >= best–10; – Grade is B if score is >= best–20; – Grade is C if score is >= best–30; – Grade is D if score is >= best–40; – Grade is F otherwise. AssignGra d e Run

Example 7.2 Using arrays in Sorting Objective: Use the selectionSort method to write a program that will sort a list of double floating-point numbers Selection Sort Run
Example 7.2 Using Arrays in Sorting ) Objective: Use the selectionSort method to write a program that will sort a list of double floating-point numbers. SelectionSort Run

Example 7.3 Testing linear search Objective: Implement and test the linear search method by creating an array of 10 elements of int type randomly and then displaying this array. Prompt the user to enter a key for testing the linear search Linearsearch Run 例74测试二分查找法
Example 7.3 Testing Linear Search ) Objective: Implement and test the linear search method by creating an array of 10 elements of int type randomly and then displaying this array. Prompt the user to enter a key for testing the linear search. LinearSearch Run 例7.4 测试二分查找法

对象的数组 Declaring and creating. Circle[] circleArray new Circle[101 G Initializing: for (int i=0; i<circleArray length; i++) circleArray [i] new Circled)i
对象的数组 ) Declaring and creating: Circle[] circleArray = new Circle[10]; ) Initializing: for (int i=0; i<circleArray.length; i++) { circleArray[i] = new Circle(); }
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第二篇 面向对象程序设计 第6章 类的继承性.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第二篇 面向对象程序设计 第5章 使用对象和类编写程序.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第一篇 程序设计基础 第4章 方法.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第一篇 程序设计基础 第3章 控制语句.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第一篇 程序设计基础 第2章 基本数据类型和基本操作.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第一篇 程序设计基础 第1章 Java入门(主讲:赵铭伟).pdf
- 江西师大:《管理信息系统》第八章 面向对象的系统开发方法.ppt
- 江西师大:《管理信息系统》第七章 管理信息系统的系统实施.ppt
- 江西师大:《管理信息系统》第六章 管理信息系统的设计.ppt
- 江西师大:《管理信息系统》第五章 管理信息系统的系统分析.ppt
- 江西师大:《管理信息系统》第四章 MIS战略规划和开发方法.ppt
- 江西师大:《管理信息系统》第三章 管理信息系统的技术基础.ppt
- 江西师大:《管理信息系统》第二章 管理信息系统概论.ppt
- 《计算机图形学》课程教学资源:计算机图形学试卷(B)答案.doc
- 《计算机图形学》课程教学资源:计算机图形学试卷(B).doc
- 《计算机图形学》课程教学资源:计算机图形学(A)答案.doc
- 《计算机图形学》课程教学资源:计算机图形学(A).doc
- 《计算机图形学》课程教学资源:2003-2004计算机图形学试卷(B)答案.doc
- 《计算机图形学》课程教学资源:2003-2004计算机图形学试卷(B).doc
- 《数学与应用数学》2003-2004数学与应用数学试卷(A).doc
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第三篇 图形程序设计 第8章 图形程序设计入门.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第三篇 图形程序设计 第9章 创建用户界面.pdf
- 大连理工大学:《Java语言程序设计》课程电子教案(讲稿)第三篇 图形程序设计 第10章 applet和高级图形界面.pdf
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第六章 大型数据库中的关联规则挖掘.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第八章 聚类分析.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)期末复习.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第九章 电子商务与数据挖掘.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第七章 分类和预测.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第一章 序论(主讲教师:王灿).ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第二章 数据仓库和数据挖掘的OLAP技术.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第三章 数据预处理.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第四章 数据挖掘原语、语言和系统结构.ppt
- 浙江大学:《数据挖掘》课程电子教案(PPT教学课件)第五章 概念描述:特征化与比较.ppt
- 《网页制作宝典》第1章 网页制作初识.ppt
- 《网页制作宝典》第10章 JavaScriptDHTML和技术.ppt
- 《网页制作宝典》第11章 示例网页利用ASP实现交互功能.ppt
- 《网页制作宝典》第12章 利用ADO实现网页与数据库的链接.ppt
- 《网页制作宝典》第2章 创建站点.ppt
- 《网页制作宝典》第3章 网页文本的处理.ppt
- 《网页制作宝典》第4章 网页表格的处理.ppt