Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1.     @Override
  2.     public boolean contains(T item) {
  3.         Object theirItem = (Object) item;
  4.         // Assume it isn't
  5.         boolean returnValue = false;
  6.         // Loop through the list
  7.         Iterator<T> myIterator = this.iterator();
  8.         try {
  9.             while (myIterator.hasNext()) {
  10.                 // If the item is what we are looking for, we found it
  11.                 Object nextItem = (Object) myIterator.next();
  12.                 if (nextItem.equals(theirItem)) {
  13.                     returnValue = true;
  14.                 }
  15.             }
  16.         } catch (NullPointerException e) {
  17.         }
  18.         return returnValue;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement