int[]数组指定位置添加元素


package cn.collection.com;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class ListDemo4 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        int[] arr = { 11, 22, 33, 44, 55 };

        // 遍历
        for (int x = 0; x < arr.length; x++) {
            int ss = arr[x];
            if (ss == 22) {//当遍历的数组值有等于22的时候
                arr[x + 1] = 88;//在当前数组位置后面添加一个88元素
            }
            System.out.println(ss);// 打印

        }

    }

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM