I've two lists with Strings as Objects. I've to compare which elements are in both Lits.
I've thoung in make two anidated For loops but don't know if are there a better way to do it.
I would think the simplest would be something like:
B4X:
Dim L1 As List = Array(1,2,3,4,8)
Dim L2 As List = Array(3,6,7,8)
Dim Results As List
Results.Initialize
For Each O As Object In L1
If L2.IndexOf(O) > -1 Then Results.Add(O)
Next
For Each O As Object In Results
Log(O)
Next
'Compare 2 lists
For x = 0 To CountryList1.Size-1
For y = 0 To CountryList2.Size-1
If (CountryList1.Get(x) == CountryList2.Get(y)) Then
Log(CountryList1.Get(x) & " are in common")
End If
Next
Next
2) You could not compare two objects, you should compare their content (unless you want to know if they are the same object or, better, the same reference to the same object)