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