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

Thrameos picture Thrameos  路  27Comments

hanslovsky picture hanslovsky  路  3Comments

tshirtman picture tshirtman  路  23Comments

Hukuta picture Hukuta  路  5Comments

cthoyt picture cthoyt  路  11Comments