java数组ArrayList

bash 复制代码
package com.controller;

import com.myThread.AdminThread;
import com.myThread.MyCallable;
import com.myThread.MyRunnable;
import model.dade;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.concurrent.*;
//上面引入*,所以这个可以注销
//import java.util.concurrent.ConcurrentHashMap;

@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AdminController{
    @GetMapping("/{id}")
    public long findById(@PathVariable Long id) throws InterruptedException {
        //可以添加任意类型数组
        //ArrayList list = new ArrayList();
        //加上类型限制,只能写这一种类型,jdk8后后面这个ArrayList可以不写<>,会引用前面这个
        ArrayList<String> list = new ArrayList();
        list.add("dade22");
        list.add("dade33");
        System.out.print(list+"\n");
        System.out.print(list.get(0)+"\n");
        list.remove(0);//删除0索引的
        list.set(0,"dade6");//修改索引0的
        System.out.print(list.get(0)+"\n");
        System.out.print(list+"\n");
        System.out.print(list.size()+"\n");//获得个数
        return id;
    }
}
相关推荐
必须会一定会6 小时前
Agent Plugins 1.0实战:plugin.json、skills、mcp.json目录结构与迁移
开发语言·人工智能·ai编程
St_rive6 小时前
Page Object设计模式
java·开发语言·设计模式
CTA量化套保6 小时前
近期零基础量化学习:先分阶段,再用 AI 检查缺口
人工智能·python
wp123_16 小时前
硬件元器件笔记|IPX8 防水 Type‑C 母座安费诺 124018802112A 与 TONEVEE TY48086‑24A 分析
c语言·开发语言·笔记
wuyk5556 小时前
4.树:一对多的层次数据结构
开发语言·数据结构·stm32·单片机
风流 少年6 小时前
Spring AI 2.0:SSE
java·人工智能·spring
清水白石0087 小时前
Python 死锁排查全攻略:从线程卡死到锁依赖定位与工程化修复
linux·网络·python
凤山老林7 小时前
精细化流量治理:Spring Boot 动态特性开关与灰度发布体系
java·spring boot·后端
Elias不吃糖7 小时前
Langfuse 入门:Trace、Prompt、Dataset、Experiment、Evaluator
前端·python·prompt·langfuse
luj_17687 小时前
桥牌思维启示:系统设计的模块化架构
c语言·开发语言·c++·经验分享·算法