博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

疯狂讲义第四章 流程控制和数组

Posted on 2011-09-27 16:21  月不识己  阅读(127)  评论(0编辑  收藏  举报

1. 三种程序的控制结构

if else, switch, for ,while ,do-while, foreach.

理解foreach的实现实质,以及使用注意事项。

2. 循环控制结构

break, continue,return 外加保留的goto.

外层循环的控制, 利用循环外面定义的结束标签 outer: 可以控制循环的层次。

3. 数组的定义和初始化,在内存中的布局。


4 java.util.Arrays;

void sort(type[] a):

采用的排序算法介绍:

sort

public static void sort(long[] a,
                        int fromIndex,
                        int toIndex)
对指定 long 型数组的指定范围按数字升序进行排序。排序的范围从索引 fromIndex(包括)一直到索引 toIndex(不包括)。(如果fromIndex==toIndex,则排序范围为空。)

该排序算法是一个经过调优的快速排序法,改编自 Jon L. Bentley 和 M. Douglas McIlroy 合著的 Engineering a Sort Function", Software-Practice and Experience Vol. 23(11) P. 1249-1265 (November 1993)。此算法在许多数据集上提供 n*log(n) 性能,这导致其他快速排序会降低二次型性能。

参数:
a - 要排序的数组
fromIndex - 要排序的第一个元素的索引(包括)
toIndex - 要排序的最后一个元素的索引(不包括)
抛出:
IllegalArgumentException - 如果fromIndex > toIndex
ArrayIndexOutOfBoundsException - 如果fromIndex < 0toIndex > a.length



5. 两个小型的练习项目:数字型浮点数人民币转换成字符串的汉子读法, 五子棋的实现

(1)浮点型数据转换成汉子字符串人民币读法

分析: