欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Remove element from list

程序员文章站 2022-04-18 19:23:24
...
@Test
public void remove_element_from_array_to_arraylist_java8 () {

    String[] daysOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday",
            "Thursday", "Friday", "Saturday"};


    List<String> daysOfWeekAsList = Lists.newArrayList(daysOfWeek);

    boolean removed = daysOfWeekAsList.removeIf(p -> p.equalsIgnoreCase("Monday"));

    logger.info(daysOfWeekAsList);

    assertTrue(removed);
    assertTrue(daysOfWeekAsList.size() == 6);
}    

转载于:https://www.jianshu.com/p/1298b2dc8379