Created
October 6, 2016 06:32
-
-
Save beta/eff89846537cc306a9e684cd448cedf5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find the class of Float | |
jclass FloatClass = env->FindClass(“java/lang/Float”); | |
// And the method ID of constructor of the Float class | |
jmethodID FloatInit = env->GetMethodID(FloatClass, “<init>”, “(F)V”); | |
for (int i = 0; i < 10; i += 1) { | |
jsize index = i; | |
// Create instances of Float | |
jobject value1 = env->NewObject(FloatClass, FloatInit, xxx); | |
jobject value2 = env->NewObject(FloatClass, FloatInit, xxx); | |
// Put the Float values into float arrays | |
env->SetObjectArrayElement(array1, index, value1); | |
env->SetObjectArrayElement(array2, index, value2); | |
} | |
// Now let’s put the float arrays into the ArrayList | |
jmethodID addElementMethod = env->GetMethodID(arrayListClass, “add”, “(Ljava/lang/Object;)Z”); | |
env->CallBooleanMethod(arrayList, addElementMethod, array1); | |
env->CallBooleanMethod(arrayList, addElementMethod, array2); | |
return arrayList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment