• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

This keeps returning false- checking if array contains object

 
Ranch Hand
Posts: 442
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


An object of type Bin contains an Array of type Item.  

It is supposed to print true as I am searching for an item the bin items list contains, but it keeps returning false.  

There has to be some error in the logic of the loops, but I can't find it.   No matter what items I put in the list where the bins contain those items, it keeps printing false.
 
Nathan Milota
Ranch Hand
Posts: 442
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, so for some reason, I concluded that the objects are not coming up as equal when they are on the two different lists.   I changed the code to...




This is more of a workaround than an ideal situation though.
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic