I think you will have to search the list yourself
The reason why I think it doesn't work.
When you create an object , in this case, the persona class object, Java assigns a unique reference to this object.
You then add it to the list , but I believe Java only stores a reference to the object in the list, not the actual object.
When you create your search persona, in the last part of your code, you are creating yet another object, that object will never be in the list unless you add it, so indexOf will always return not found in list.
You can check this by storing a copy of an object, then using that in the search, indexOf will return the correct item number.
Dim l As List
l.Initialize
Dim test As smallclass
'==== smallclass def in class module ====
'Dim n As Int
'Dim s As String
'Public Sub Initialize (nn As Int,ss As String)
'n = nn
's = ss
'End Sub
'===================
For p = 0 To 10
Dim rec As smallclass
rec.Initialize(p,"rec"&p)
If p = 2 Then test = rec ' save a copy of this object
l.Add(rec)
Next
Log(l)
Dim f As smallclass
f.Initialize(2,"rec2")
Log(f)
Log(test)
Log(l.IndexOf(f)) ' fails - object not in list
Log(l.IndexOf(test)) ' as test is a copy of rec2 it is found in list
Log(f = test) ' will return false as they are not the same object
In my example above you can add two routines to the class to enable you to get the index
Public Sub compareTo(r As smallclass) As Boolean
If n = r.n AND s = r.s Then
Return True
Else
Return False
End If
End Sub
Public Sub indexInList(l As List) As Int
Dim reply As Int = -1
For i = 0 To l.Size -1
Dim tt As smallclass
tt = l.Get(i)
If n = tt.n AND s = tt.s AND reply = -1 Then reply = i
Next
Return reply
End Sub
then you can use
Log(f.compareTo(test))
Log("in list pos : " & f.indexInList(l))
The first line will return true, even though they are different objects.
The second will return the position in the list of the item (zero based) or -1 if not found in list.
Hope this helps.