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