Last active
June 10, 2020 00:04
-
-
Save forAllBright/51d79369040e8e6b185f01797a2ea797 to your computer and use it in GitHub Desktop.
Java Tricks #Java #FalliblePoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 在 for 的高级用法中不能动态的删除集合元素。 | |
public class Test { | |
public static void main(String[] args) { | |
ArrayList<String> str = new ArrayList<>(); | |
str.add("h"); | |
str.add("e"); | |
str.add("ll"); | |
str.add("o"); | |
for(String i:str) { | |
if(i.equals("e")) { | |
str.remove(i); | |
} | |
} | |
System.out.println(str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can u help me with this code? I'm a beginner