Android ArrayList iteration
android, arraylist
Solution
for (String area : area_IdList)
{
for (String duplicatedArea : area_IdListduplicate)
{
if (!area.equalsIgnoreCase(duplicatedArea))
{
// some decision
}
}
}
This is more efficient, goes faster instead of iterating by indexes. So this will check step by step each element in `area_IdList` with all elements in `area_idListduplicate` and each time they don't mach, this decision will be made. (If that's what you want achieve)
Problem
I have an ArrayList which stores Area names. I want to check this list to find whether arbitrary people are from different area. If they are from different area, i take a decision. I achieved this with the following code. Note that area_IdList and area_IdListduplicate are essentially the same ArrayList. Is this code efficient or can anyone suggest more efficient code ? Thanks in Advance. ``` public List<String> area_IdList = new ArrayList<String>(); public List<String> area_IdListduplicate = new ArrayList<String>(); for (int i = 0; i < area_IdList.size(); i++) { for (int k = 1; k< area_IdListduplicate.size(); k++) { String sa= area_IdListduplicate.get(k); String sb= area_IdList.get(i); if (!sa.equalsIgnoreCase(sb)) { some decision } } } ```