function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mobile vistexmobile vistex 

how to compare two values in for each loop

HI i have written a loop like
for(String x: <list>){
k=x[0];
l=x[1];

}


my question is how to compare values k..

 
bob_buzzardbob_buzzard
I don't understand the question I'm afraid - what are the values that you are trying to compare?  Is is the current value and previous, current and next, or something else.

What is the purpose of the comparison - are you trying to order the collection in some way?
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Hi,

Use string indexOf method
for(String x: <list>){
	k=x.indexOf(0);
	l=x.indexOf(1);
	//Comparision
	if(k==l){
		//Your login here
	}

}
Let us know if it helps you.