1 回答

TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個贊
從 C++調(diào)用Integer#valueOf(int)并將結(jié)果傳遞給HashMap#put(Object, Object):
jclass j_Integer = env->FindClass("java/lang/Integer");
jmethodID j_Integer_valueOf = env->GetStaticMethodID(j_Integer, "valueOf", "(I)Ljava/lang/Integer;");
jmethodID put = env->GetMethodID(mapClass, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
for (auto &it: m_values) {
jobject j_intValue = env->CallStaticObjectMethod(j_Integer, j_Integer_valueOf, it.second);
env->CallObjectMethod(hashMap, put, env->NewStringUTF(it.first.c_str()), j_intValue);
}
添加回答
舉報(bào)