数组与LIST相互之间的转化

来源:互联网 发布:淘宝营销活动规则 编辑:程序博客网 时间:2024/06/07 04:07

数组转变为list,调用Arrays类的静态方法asList。

 Integer[] ar = new Integer[]{1,2,3};        List<Integer> i = Arrays.asList(ar);

list转变为数组,调用toArray方法。

 List<Long> list = new ArrayList<>();        List<GamePlatform> games = gamePlatform.getUseGames(status, platformId);        for(GamePlatform game : games) {            list.add(game.getGameId());        }        Long[] arr = list.toArray(new Long[list.size()]);
原创粉丝点击