[精讚] [會員登入]
501

ArrayList 想移除特定值

想移出water, 使用lambda 的方式如下 List<String> fruits = new Arr

分享此文連結 //n.sfs.tw/13242

分享連結 ArrayList 想移除特定值@igogo
(文章歡迎轉載,務必尊重版權註明連結來源)
2019-04-11 11:32:40 最後編修
2019-04-11 11:49:56 By igogo
 

 

想移出water,  使用lambda 的方式如下


    List<String> fruits = new ArrayList<>();
        Arrays.asList("apple", "orange","water").forEach(fruit -> fruits.add(fruit));
      

        (fruits.stream()
                .filter(item -> !item.equals("water"))
                .collect(Collectors.toList())
        ).forEach(fruit -> System.out.println(fruit));

 

END

你可能感興趣的文章

java-身份証字號驗証 FormatCheck.java public class FormatCheck { private volatile

java.time 時間 instant java.time

讀取特定資料夾下的xls檔 讀取特定資料夾下的xls檔

使用poi 解析 docx 原先是想解析出在docx 中的文字跟圖片, 但是, 有些我們認為是圖片, 其實是用方程式表示, 實在是太麻煩了 就記錄一

刪除資料夾內的檔案 lambda 一行文 Arrays.stream(new File("/folder/path").

spring boot jpa 使用多個欄位排序 我有一entity 叫 team 資料欄下如下 @Id @GeneratedValue(strategy = Gener

隨機好文

編碼的順序 utf8 big5

讀取特定資料夾下的xls檔 讀取特定資料夾下的xls檔

用java讀取microbit寫到serial的資料 用java讀取microbit寫到serial的資料

spring boot 3 建立 Basic Authentication 參考以下網站, 建立一個http basic authentication 為例 https://www.geeksfo

python 解析資料, 輸入並輸出 database, csv, pdf(二) 延續上篇 https://n.sfs.tw/content/index/16452 parse html class B