Java Question Returning an array

tchart

Well-Known Member
Licensed User
Longtime User
Sorry if this has been covered elsewhere, I have searched the forum and cant find anything.

So I have a library which wraps a custom type called Graphic - the wrapper being GraphicWrapper.

Now in another class I have method that returns an array of graphics (ie public Graphic[] getGraphics() etc)

In b4a Im getting the "inconvertible types"

One of the types being reported is Graphic[] and the other is GraphicWrapper[]

How do I deal with this?

1) I have tried to return GraphicWrapper[] but this seems troublesome as I cant easily create an array of GraphicWrappers

2) As a work around I have successfully returned a b4a List of Graphic objects and this works well.

Is approach #2 advisable or is there a better way to handle this?
 

tchart

Well-Known Member
Licensed User
Longtime User
You can either create an array of GraphicWrappers or a List of Graphic objects. Both solutions are good.

Erel,

Thanks for the reply.

Is there an easy way to create/copy the array? Or do I need to loop through each one and use setobject?
 

tchart

Well-Known Member
Licensed User
Longtime User
Thanks Erel, I tried the array method but it was too cumbersome. Ive stuck with returning a B4A List object which works nicely.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…