You need to sign in to do that
Don't have an account?

How to find if a particular value is in the list?
Is there anything like function "ListFind" in apex.
such that ListFind(a,b) returns true or false depending on if an element "b" is there in list "a" or not.
hi arosys..... you can find it by using SET...just check "contains" method in SETs ..add that list to a set. go for this link
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_set.htm
I need to do it through lists only because later i will need its position also.
Arosys,
Well this is one of the problem that I generally face in!
So the workaround is having a Map(beacuse you need index else set can be used) and List Together.
have a look at following example[this will save couple of iterations that you will be doing to locate a particular value in list]
PS : This will fail in case you have multiple account with same name, it will give you the index of the last one only
then you can try loop ...for example
//list of account
List<String> ListOfString;
//you want to find "xx" from ListOfString
//loop through the list
for(string str : ListOfString){
//check for the value
if(str == xx){
//TODO Operation
}
}
Try something like
You just need to change List<String>, String and Set<String> to match your type requirements.
Hope this helps.
https://releasenotes.docs.salesforce.com/en-us/spring18/release-notes/rn_apex_new_classes_methods.htm#rn_apex_new_classes_methods