I am adding A, B and C to array list. how can I check if array list contains A, B and C than set id variable as 1. Or is there a better way to do this. I just want to set id variable as 1,2 or 3 depending upon the value inside Array list. For example if array list contains A, B and C than id = 1 and if array list contains A, B, C and D than id = 2;
Share
You can use ArrayList.contains(Object elem) method for this purpose. It returns
A small code snippet to give you some idea.
So, Output =
1.