//7.集合转数组
//https://www.cnblogs.com/goloving/p/7693388.html
//http://localhost:8000/dealConstant
@RequestMapping("/listToArray")
public  void  listToArray(){
    // list转数组
   List<User> list = new ArrayList<>();
    User user = new User();
    user.setId(UUID.randomUUID().toString());
    user.setCreateTime(TimeUtils.getStringDate(new Date()));
    user.setSex("2");
    user.setName("测试1");
    list.add(user);
    //集合转数组    注意数组类型
    User[] array=list.toArray(new User[list.size()]);
    System.out.println(array);
    //数组转集合
    List<User> arrToList = Arrays.asList(array);
    System.out.println(arrToList);
}

22.集合数组之间相互转换-LMLPHP

07-09 15:01