function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi All,
How To Identify a List Item is exist or not in a list?. Please don't suggest me Map/Set.
Thanks in Advance.
For ex, you have an String List and you are searching for a value in it, lets say sfdc.
You have to iterate the list in order to find the value
Have a Boolean value that will determine whether the value existed in List or not
Boolean flag = false;
for(String s: stringList)
{
if(s == 'sfdc')
flag = true;
}
if(flag == true)// The flag will be true only if the value you looked for exists in list
//your code
If you are just looking for a first occurence then you can add break statement inside the loop so that you no need to traverse till end of the list..... Just a small tip :)
Guys hold on this. Finally I have fixed this.
Thanks to all for your help. :smileyvery-happy:
For ex, you have an String List and you are searching for a value in it, lets say sfdc.
You have to iterate the list in order to find the value
Have a Boolean value that will determine whether the value existed in List or not
Boolean flag = false;
for(String s: stringList)
{
if(s == 'sfdc')
{
flag = true;
}
}
if(flag == true)// The flag will be true only if the value you looked for exists in list
{
//your code
}
If you are just looking for a first occurence then you can add break statement inside the loop so that you no need to traverse till end of the list..... Just a small tip :)
Guys hold on this. Finally I have fixed this.
Thanks to all for your help. :smileyvery-happy: