Link to home
Start Free TrialLog in
Avatar of sakthikumar
sakthikumar

asked on

usage of contains in Arraylist

I have an Arraylist, which is based on a class containing below properties.

private String selection;
private String choice;

so Arraylist will contain objects, with each containing above properties.

I have a value for selection. I want to check this value is available in property selection
in any of the object in the list, without using a loop.

Is there any way to achieve this?
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jb1dev
jb1dev


set.put(selection);

Sorry, that should be
set.add(selection);