ArrayList
1 List<ApiSvcVersion> apiSvcVersionList = apiSvcVersionDao.getListByClientId(map1); //获取List
2 // 根据 CLIENT_ID判断【 前端秘钥】是否使用
3 if (null == apiClientSvcInstRelaList || apiClientSvcInstRelaList.size() == 0) {
4 // 根据 CLIENT_ID判断【 后端秘钥】是否使用
5 if (null == apiSvcVersionList || apiSvcVersionList.size() == 0) {
6 apiClientDefineDao.delete(apiClientDefine);
7 } else {
8 ArrayList<String> arrayList = new ArrayList<>(); //新建ArrayList
9 for (ApiSvcVersion apiVer : apiSvcVersionList) { //for循环,为了添加add元素
10 arrayList.add(apiVer.getDisplayName());
11 }
12 for (ApiSvcVersion apiVer : apiSvcVersionList) {
13 throw new RuntimeException("该密钥已被版本" + arrayList + "使用!请解绑后再尝试删除。");
14 } // arrayList是个数组,在这里可以[a,b,c,....等]这样显示
15 }
16 } else {
17 throw new RuntimeException("该密钥已绑定服务实例,请执行解绑操作后再尝试删除!");
18 }
-----------------------------------------------------------------------------------------------
1 import java.util.ArrayList;
2 import java.util.List;
3
4 public class ArrayTest {
5 public static void main(String[] args) {
6 ArrayList<String> arraylist = new ArrayList<>();
7 arraylist.add("a");
8 arraylist.add("b");
9 System.out.println(arraylist);
10
11 }
12 }
结果: [a, b]