This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how do you find out if ids of objects in an array are present Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how do you find out if ids of objects in an array are present " Watch "how do you find out if ids of objects in an array are present " New topic
Author

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

Jason Rodrigues
Greenhorn

Joined: Oct 20, 2005
Posts: 21
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

Joined: Oct 13, 2005
Posts: 38057
    
  22
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

Joined: Oct 13, 2005
Posts: 38057
    
  22
. . . and please check your private messages for an important administrative matter.

CR
 
 
subject: how do you find out if ids of objects in an array are present
 
Similar Threads
Hibernate join into single object
arrays
incompatible types
ClassCastException in Tag Library
Copy objects from one array over to another