This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do you find out if ids of objects in an array are present

 
Jason Rodrigues
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Lets say i have an object A with id as an attribute and its type is int. I fill the array list with the A type objects. i want to check if the id in the object A exist.
Is there a way i can do it without looping through the entire collection, get the object A and comparing A.id to XXX to find if it exists ? Is there a way i can use the conatins to extract the id ?
Thank you
Reeve
 
Campbell Ritchie
Sheriff
Posts: 48409
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is your contains() method from? Unless you have got something with a suitable contains() method, you will probably have to go through the array element by element.
 
Campbell Ritchie
Sheriff
Posts: 48409
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and please check your private messages for an important administrative matter.

CR
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic