SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:Welcome to the Ranch!
You should not use AllocObject, as that does not call any of the class constructors. Use GetMethodID to get the constructor to use, using "<init>" as the method name, then use NewObject, NewObjectA or NewObjectV to call that constructor.
Because you used AllocObject the byte array is not instantiated and therefore still null.
Rob Spoor wrote:
You should not use AllocObject, as that does not call any of the class constructors. Use GetMethodID to get the constructor to use, using "<init>" as the method name, then use NewObject, NewObjectA or NewObjectV to call that constructor.
Because you used AllocObject the byte array is not instantiated and therefore still null.
satya prakash panigrahi wrote:But still couldn't get one thing, with env-AllocObject i was able to operate on the primitive variables present inside the class, but not on the arrays. Why? What has the default constructor got to do here?
satya prakash panigrahi wrote: I am trying this way:
Now, I am trying to change the value of str in following ways:
OR, like this:
By using SetObjectField, I am able to change the values inside my byte array, but it's not happening for the String variable.
I don't know what is wrong, but str value remains NULL even after putting "hellohi" inside it.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Space pants. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|