关于二分查找和选择排序参考:二分查找和选择排序
一、数组的排序方式
选择排序
当运行到最后一个元素的时候,它已经和前面所有的元素比较过了,所以次数是length-1;

冒泡排序

二位数组的初始化

二维数组的遍历
利用双重for循环遍历,前提是数组的两个长度都是已知的。
可以是图一这样后定义第二个长度,然后进行遍历

也可以图二这样直接定义两个长度,然后遍历

二维数组长度的获取
arr.length获取的是整个数组的行数
arr[i].length获取的是数组中某一行的元素个数,该行数组的长度
打印杨辉三角


打印成等腰三角形也可以


字符串
创建方法

1 String s1 = new String(); //创建String对象,字符串中没有内容 2 byte[] bys = new byte[]{97,98,99,100}; 3 String s2 = new String(bys); // 创建String对象,把数组元素作为字符串的内容 4 String s3 = new String(bys, 1, 3); //创建String对象,把一部分数组元素作为字符串的内容,参数offset为数组元素的起始索引位置,参数length为要几个元素 5 String s6 = new String(“abc”); //创建String对象,字符串内容为abc
字符串的比较方法
==比较地址
equals比较内容

返回true , false
解释
