wiley_pastebin

lesson 4 defensive 1

Mar 15th, 2019
2,249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.30 KB | None | 0 0
  1. public class Database {
  2.  private ArrayList<Item> items;
  3.  //...
  4.  
  5.  public boolean removeItem(String title){
  6.   for(int i = 0; i < items.size(); i++){
  7.    if(items.get(i).getTitle().equals(title)){
  8.    items.remove(i);
  9.    return true;
  10.   }
  11.  }
  12.  // item not found
  13.  return false;
  14.  }
  15.  
  16.  //...
  17. }
Advertisement
Add Comment
Please, Sign In to add comment