首页 > 其他分享 >将一定范围的值 放在数组中

将一定范围的值 放在数组中

时间:2023-01-17 21:33:55浏览次数:56  
标签:cha index int 放在 数组 100 public 范围

package com.fqs.demo;

public class fangArray {
    public static void main(String[] args) {
        //将100到105的数放数组中
        int a=100;//开始的值 包含自身
        int b=105;//结束的值 包含自身
        int cha=b-a+1;
        int array[]= new int[cha] ;//定义一个固定长度的数组
        for(int index=0;index<cha;index++) {//循环将1,2,3...9放入数组中
            array[index]=a;
            a++;
            System.out.println("array[index]:"+array[index]);
        }
        
        
    }

}

 

标签:cha,index,int,放在,数组,100,public,范围
From: https://www.cnblogs.com/haha1988/p/17058718.html

相关文章