小编Ken*_*ong的帖子

删除列表的最后一个元素

我的任务是在ArrayList的新手Java教程中执行以下操作

// 1) Declare am ArrayList of strings
    // 2) Call the add method and add 10 random strings
    // 3) Iterate through all the elements in the ArrayList
    // 4) Remove the first and last element of the ArrayList
    // 5) Iterate through all the elements in the ArrayList, again.
Run Code Online (Sandbox Code Playgroud)

以下是我的代码

import java.util.ArrayList;
import java.util.Random;

public class Ex1_BasicArrayList {

    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();
        for (int i = 0; i <= 10; i++){ …
Run Code Online (Sandbox Code Playgroud)

java arraylist

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

arraylist ×1

java ×1