[精讚] [會員登入]
546

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

你可能感興趣的文章

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

Spring Boot Maven wrappers maven, mvnw, build command

java lambda files filter java, files filter, lambda

利用maven建立一個可執行的jar檔 利用maven建立一個可執行的jar檔

Arrays.asList 後想再add出現 UnsupportedOperationException 這個問題真是搞死我了 List<String> fruits = Arrays.asList("a

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

隨機好文

tmux 將終端機切割成多個視 窗 tmux, multiple terminal

vue.js components 多個組件的呈現 vue.js 組件 component

[vue.js] 設定 content type 今天在wickt 端怎麼就是收不到vue.js 以post 傳過來的資料 找了好久才發現 application/jso

[vue.js] 動態的props 做parent-child components 雙向綁定 vue.js props components camel-case

centos 7 移机出現 dracut-initqueue timeout centos 7 移机出現 dracut-initqueue timeout 處理