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;
    }
}
相关推荐
AI创界者1 分钟前
Python 进阶实战(七十一章):研发效能度量、自动化质量门禁与工程规范落地实战
人工智能·python·aigc
yingjie11026 分钟前
快榜GEO|官网 AI 可读性自查 12 项(附 Python 检测脚本)
开发语言·人工智能·python
Felven43 分钟前
C. Make Them Equal
c语言·开发语言·前端
tryCbest1 小时前
Python 爬虫扩展篇(二):验证码的检测与人工介入——把“拦路虎”当作信号,而不是要征服的对手
开发语言·爬虫·python
Rain的Java大神之路2 小时前
10万QPS订单系统:缓存、ES、MQ三道连环题,我把踩过的坑一次讲透
java·后端·面试
Rain的Java大神之路2 小时前
LeetCode 45 跳跃游戏 II:大厂面试官最爱追问的贪心题,我把骨头给你拆干净了
java·后端·leetcode
风落青芜3 小时前
排序算法(四):归并排序、计数排序与算法总结
c语言·开发语言·数据结构·算法·排序算法
Resean02233 小时前
讲透Java(14)泛型的本质:类型擦除与桥接方法
java·开发语言
@陈小鱼3 小时前
基于InceptionTime网络的PPG无创血压估计算法研究
人工智能·python·算法·回归·开源·ppg·血压估计