zoukankan      html  css  js  c++  java
  • 数组

    数组的定义:数组类型 [] 数组名 = new 数组类型[数组长度];

    数组初始化:数组类型 [] 数组名 = {数组元素1,数组元素2,数组元素3};

    数组类型 [] 数组名 = new 数组类型[]{数组元素1,数组元素2,数组元素3};

    数组长度:数组名.length

    数组遍历:for(int i=0;i<数组名.length;i++){

          }

    主要就是要注意数组下标索引是从0开始!

    数组冒泡排序:

            int [] nums={21,3,4,87,2};
            for (int i = 0; i < nums.length-1; i++) {
                for (int j = 0; j < nums.length-i-1; j++) {
                    if (nums[j]>nums[j+1]) {
                        int temp=nums[j+1];
                        nums[j+1]=nums[j];
                        nums[j]=temp;
                    }
                }
                
            }
  • 相关阅读:
    IEnumerator & IEnumerable
    GameObject.Active
    Unity3D的四种坐标系
    gvim
    Platform Dependent Compilation
    delegate
    new 约束
    UIPanel
    UIButton
    UISprite
  • 原文地址:https://www.cnblogs.com/xty1994/p/6622258.html
Copyright © 2011-2022 走看看