### Convert Java Array to B4J List

This is an example of converting a Java Array to a B4J List.
'Declare and init the list
Dim l As List : result.Initialize
'Declare the object array which holds the items from the Java class method
Dim a() As Object
'Add the values returned from the Java class method - idc from the Pos Enum (https://docs.oracle.com/javafx/2/api/javafx/geometry/Pos.html)
a = joJavaEnum.RunMethod("values", Null)
'Convert the array of objects into a list of strings
For i = 0 To a.Length - 1
l.Add(a(i))
Next
Above example converted into a Sub
'Build list of constants for the Enum Pos
`Sub EnumPosConstants As List
Dim result As List : result.Initialize
'Declare the JavaObject for the Java Enum Pos
Dim joJavaEnum As JavaObject
'Initialize the JavaObject as static to be able to access the enum methods
joJavaEnum.InitializeStatic("javafx.geometry.Pos")
'Get the java enum values and store in an array of objects - because the class method values returns an array
Dim l() As Object
l = joJavaEnum.RunMethod("values", Null)
'Convert the array of objects into a list of strings
For i = 0 To l.Length - 1
result.Add(l(i))
Next
Return result
End Sub`

Changed: , Category: JavaObject, File: T6C208M1521.htm, ID: 1521