将1到10 10个值 放入数组中

将1到10,10个数放到一个数组中

package com.fqs.demo;

public class fangArray {
    public static void main(String[] args) {
        //将1到10的数放数组中
        int array[]= new int[10] ;//定义一个固定长度的数组
        for(int index=0;index<10;index++) {//循环将1,2,3...9放入数组中
            array[index]=index+1;
            System.out.println("array[index]:"+array[index]);
        }
        
        
    }

}

 

posted @ 2023-01-17 21:04  胖豆芽  阅读(110)  评论(0编辑  收藏  举报