List<Integer> list = Arrays.asList(ids.split("-")).stream().map(s -> Integer.parseInt(s.trim())).collect(Collectors.toList());
ids代表用 '-' 字符連接數字的字符串,格式如下所示:“1-2-9-15”這種
String類的成員方法split(String reg)將字符串根據參數字符串類型進行分割,得到字符串數組,如上述數組即被分為{"1","2","9","15"}
Arrays.asList(對象數組) 【不可是基礎類型,需為包裝類】將對象數組轉換為List<該類型>。
List之stream()方法 將集合轉化為流Stream對象,以便對集合進行操作
map(A -> B)是流對象的方法,遍歷流中的數據 s 將其從A形態轉換為B形態,例如上述代碼就是將字符串轉化為Integer類型的Stream對象
collect(Collectors.toList()) Stream類對象,將Stream轉換為List類型