一维数组

创建数组(Create an array) alt

 data type [] arry= new data type[length];

获取长度(Get length):

int length =  arr.length;

访问具体元素(Access specific elements)

  arry[Subscript];

赋值(Assignment)arry[subscript]=value; 遍历数组(Traversal array) Method of one(for method):

for(i=0;i<length;i++){ 

System.out.println(arry[i]);

} 

创建数组并附值(Create an array and attach values.)

int[] arry = new int[]{element,element,...};

基本操作(Basic operation)
    // 扩容(Expand capacity) 添加元素(Add element)
        //step1:  int[] newArray = new int[array.lengrh+increase];
        //step2:   for(int i =0 ; i<array.length;i++){
                    newArray[i] = array[i];
        }
        //step3:   int a = value; newArry[array.length] = a;
        //step4: arrary = newArrary;
    //删除元素(Delete element):
        //step1 :int[] newArray = new int[array.length-1];  
                  int a = value;
       // step2:   for(int i =0 ; i<newArray.length-1;i++){
        if(i<i){newArray[i] = arry[i];
        }eles{
        newarray[i]=arry[i+1];
        }
       // step3:  array=newArray;

面向对象 数组(Object-oriented array) 写方法对数组进行操作(The write method operates on the array) 可变数组

Myarray    ma = new Myarray();

线性查找: 从左到右一一比对(Linear search: one by one from left to right)

二分法查找: 有序数组多次一分为二,分别查找(Dichotomy search: the ordered array is divided into two for many times and searched separately)

alt

全部评论

相关推荐

11-03 14:38
重庆大学 Java
AAA求offer教程:我手都抬起来了又揣裤兜了
点赞 评论 收藏
分享
预计下个星期就能开奖吧,哪位老哥来给个准信
华孝子爱信等:对接人上周说的是这周
投递华为等公司10个岗位 >
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务