B4J Question How to cast to java.util.Vector

GGSoft

Member
Licensed User
Longtime User
I am working with a .jar external library and I need to send a java.util.Vector data to one of its methods. How can I cast that type of data or convert a B4X array or a B4X list to a vector?

The library's documentation says:
B4X:
public void setNoteList(java.util.Vector newNoteList)
Replaces the entire note list with a new note list vector
Parameters:
Vector - of notes

Thanks in advance.
 

stevel05

Expert
Licensed User
Longtime User
Check the java.util.Vector Docs - https://docs.oracle.com/javase/8/docs/api/java/util/Vector.html, there is a constructor that will create a Vector from a Collection, so using JavaObject it should be :

B4X:
Dim L As List = Array As Int(1,2,3,4,5)

Dim Vector As JavaObject
Vector.InitializeNewInstance("java.util.Vector",Array(L))

Log(Vector)
 
Upvote 0
Top