Pyjnius: Make it possible to convert a python list to a Java array

Created on 29 Sep 2012  ·  3Comments  ·  Source: kivy/pyjnius

There is an internal function to do this, but it not accessible in Python

bug

Most helpful comment

Found the functionality; would be super-helpful to add such examples to the documentation.

>>> jArray = autoclass("java.lang.reflect.Array")
>>> a = jArray.newInstance(jString, 10)
>>> a
[None, None, None, None, None, None, None, None, None, None]
>>> a[0] = jString("nitish")
>>> a
[<java.lang.String at 0x103d619b0 jclass=java/lang/String jself=<LocalRef obj=0x7fc665f4a3f8 at 0x103abf190>>, None, None, None, None, None, None, None, None, None]

This wasn't trivial at all.

All 3 comments

fixed by you sir!

It's been about 6 years since this question, so lots might have changed:
I was looking for such functionality (i.e. converting python list to Java array), but didn't find anything in the documentation.

Found the functionality; would be super-helpful to add such examples to the documentation.

>>> jArray = autoclass("java.lang.reflect.Array")
>>> a = jArray.newInstance(jString, 10)
>>> a
[None, None, None, None, None, None, None, None, None, None]
>>> a[0] = jString("nitish")
>>> a
[<java.lang.String at 0x103d619b0 jclass=java/lang/String jself=<LocalRef obj=0x7fc665f4a3f8 at 0x103abf190>>, None, None, None, None, None, None, None, None, None]

This wasn't trivial at all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tom19952000 picture tom19952000  ·  15Comments

tshirtman picture tshirtman  ·  23Comments

apalala picture apalala  ·  7Comments

cthoyt picture cthoyt  ·  11Comments

Thrameos picture Thrameos  ·  27Comments