Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void testRemovalFromListTwo() {
- List<SomeItem> list = new ArrayList<SomeItem>();
- list.add(new SomeItem("Penny", 1));
- list.add(new SomeItem("Nickle", 5));
- list.add(new SomeItem("Dime", 10));
- list.add(new SomeItem("Quarter", 25));
- list.add(new SomeItem("Dollar", 100));
- System.out.println("List contains: "+list);
- System.out.println("Removing anything with a value below 25 cents from list");
- int size = list.size()-1;
- for(int i=size;i>=0;i--) {
- if (list.get(i).value < 25) {
- list.remove(i);
- }
- }
- System.out.println("List now contains: "+list);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement