Remove specific string from arraylist elements containing a particular subsrtring

后端 未结 5 635
我寻月下人不归
我寻月下人不归 2021-01-24 15:00

Here is my code for arrayList ,

 String[] n = new String[]{\"google\",\"microsoft\",\"apple\"};
      final List list =  new ArrayList

        
5条回答
  •  感情败类
    2021-01-24 15:44

    Why to add and then remove ?

    Check before adding.

        String[] n = new String[]{"google","microsoft","apple"};
         final List list =  new ArrayList();
         for (String string : n) {
             if(string.indexOf("le") <0){
                list.add(string);
            }
        }
    

    That add's only one element microsoft to the list.

提交回复
热议问题