简体   繁体   中英

Declaring a variable as float I get java.lang.IllegalArgumentException: Can not set java.lang.Float field

I'm using jython for writing test cases and I need to declare a variable as float. I am declaring this way:

width = float(10.0)
Height = float(40.0)

I'm getting this error:

java.lang.IllegalArgumentException: Can not set java.lang.Float field com.ganz.tt.user.service.client.featurecodemanager.CreateVillagerSvc$Request.width to java.lang.Double
 at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
 at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)

My guess would be to use java double type instead of float. Python uses usually doubles to represent floats.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM