java数组ArrayList

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;
    }
}

你可能感兴趣的:(java,python,开发语言)