From fca9ec8983000b0e7edc61f52c2d288fadad5bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E8=85=BE=E6=B5=A9?= Date: Tue, 28 May 2019 20:54:28 +0800 Subject: [PATCH] =?UTF-8?q?Java=E5=BC=80=E5=8F=91=E8=80=85=E5=BF=85?= =?UTF-8?q?=E7=BB=8F=E4=B9=8B=E5=9D=91:remove=20in=20foreach?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- java/Remove.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 java/Remove.java diff --git a/java/Remove.java b/java/Remove.java new file mode 100644 index 0000000..6f97f24 --- /dev/null +++ b/java/Remove.java @@ -0,0 +1,15 @@ +import java.util.List; + +public class Remove { + + /** + * 移除特定元素 + */ + public static void remove(List items){ + for (String item : items) { + if (item.equals("abc")) { + items.remove(item); + } + } + } +} -- Gitee