Created
August 27, 2016 02:27
-
-
Save jayjaykim/84d631a5cadc66cc787004fcf90ed604 to your computer and use it in GitHub Desktop.
remove an entry in for-loop statement
This file contains hidden or 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
public class TestList { | |
public static void main(String[] args) { | |
String[] strings = {"hi", "hello", "mine", "you"}; | |
List<String> list = Lists.newArrayList(strings); | |
// item or entry == 항목 | |
System.out.println("list : " + list); | |
final int size = list.size(); | |
for(int i = size - 1; i >= 0; i--) { | |
if("mine".equals(list.get(i))) { | |
// TODO: 2016. 8. 27. remove the item | |
list.remove(i); | |
} | |
} | |
System.out.println("list : " + list); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment