Google latinIME

將聯(lián)想詞邏輯移植到ios上要功課三大難題稠通。
第一大難題:C中的邏輯是從apk文件中獲取dict文件,也就是將dict文件用其他方式獲取
讀取dict文件主要邏輯
java

private static ReadOnlyBinaryDictionary createReadOnlyBinaryDictionary(final Context context,
            final Locale locale) {
        AssetFileDescriptor afd = null;
        try {
            final int resId = DictionaryInfoUtils.getMainDictionaryResourceIdIfAvailableForLocale(
                    context.getResources(), locale);//獲取dict文件資源ID
            if (0 == resId) return null;
            afd = context.getResources().openRawResourceFd(resId);//通過ID得到AssetFileDescriptor對(duì)象
            if (afd == null) {
                Log.e(TAG, "Found the resource but it is compressed. resId=" + resId);
                return null;
            }
            final String sourceDir = context.getApplicationInfo().sourceDir;
            final File packagePath = new File(sourceDir);
            // TODO: Come up with a way to handle a directory.
            if (!packagePath.isFile()) {
                Log.e(TAG, "sourceDir is not a file: " + sourceDir);
                return null;
            }
            return new ReadOnlyBinaryDictionary(sourceDir, afd.getStartOffset(), afd.getLength(),
                    false /* useFullEditDistance */, locale, Dictionary.TYPE_MAIN); //返回相關(guān)信息
        } catch (android.content.res.Resources.NotFoundException e) {
            Log.e(TAG, "Could not find the resource");
            return null;
        } finally {
            if (null != afd) {
                try {
                    afd.close();
                } catch (java.io.IOException e) {
                    /* IOException on close ? What am I supposed to do ? */
                }
            }
        }
    }

以上是java獲取相關(guān)文件信息參數(shù)殖妇,通過ReadOnlyBinaryDictionary 傳遞到native層刁笙,調(diào)用openNative參數(shù),openNative通過動(dòng)態(tài)注冊(cè)的方式實(shí)現(xiàn)拉一。

{
        const_cast<char *>("openNative"),
        const_cast<char *>("(Ljava/lang/String;JJZ)J"),
        reinterpret_cast<void *>(latinime_BinaryDictionary_open)
 }



static jlong latinime_BinaryDictionary_open(JNIEnv *env, jclass clazz, jstring sourceDir,
        jlong dictOffset, jlong dictSize, jboolean isUpdatable) {
    PROF_INIT;
    PROF_TIMER_START(66);
    const jsize sourceDirUtf8Length = env->GetStringUTFLength(sourceDir);
    const char *str = env->GetStringUTFChars( sourceDir, 0);
    LogUtils::logToJava(env, "this is sourceDir : %s",str);
    if (sourceDirUtf8Length <= 0) {
        AKLOGE("DICT: Can't get sourceDir string");
        return 0;
    }
    char sourceDirChars[sourceDirUtf8Length + 1];

    env->GetStringUTFRegion(sourceDir, 0, env->GetStringLength(sourceDir), sourceDirChars);//將字符串放入預(yù)先設(shè)置好的緩沖區(qū) sourceDirchars中不需要事后釋放
    sourceDirChars[sourceDirUtf8Length] = '\0';//代表空字符 字符串結(jié)束的標(biāo)語
    DictionaryStructureWithBufferPolicy::StructurePolicyPtr dictionaryStructureWithBufferPolicy(
            DictionaryStructureWithBufferPolicyFactory::newPolicyForExistingDictFile(
                    sourceDirChars, static_cast<int>(dictOffset), static_cast<int>(dictSize),
                    isUpdatable == JNI_TRUE));
    if (!dictionaryStructureWithBufferPolicy) {
        return 0;
    }

    Dictionary *const dictionary =
            new Dictionary(env, std::move(dictionaryStructureWithBufferPolicy));//std::move可以以非常簡(jiǎn)單的方式將左值引用轉(zhuǎn)換為右值引用


    PROF_TIMER_END(66);
    return reinterpret_cast<jlong>(dictionary);
}

--------------------------------------------------------------------------------------------------------------
/* static */ DictionaryStructureWithBufferPolicy::StructurePolicyPtr
        DictionaryStructureWithBufferPolicyFactory::newPolicyForExistingDictFile(
                const char *const path, const int bufOffset, const int size,
                const bool isUpdatable) {
    if (FileUtils::existsDir(path)) {
        // Given path represents a directory.
        AKLOGE("One file dictionaries don't support updating. path: %s", path);
        return newPolicyForDirectoryDict(path, isUpdatable);
    } else {
        if (isUpdatable) {
            AKLOGE("One file dictionaries don't support updating. path: %s", path);
            ASSERT(false);
            return nullptr;
        }
        return newPolicyForFileDict(path, bufOffset, size);
    }
}

----------------------------------------------------------------
/* static */ DictionaryStructureWithBufferPolicy::StructurePolicyPtr
        DictionaryStructureWithBufferPolicyFactory::newPolicyForDirectoryDict(
                const char *const path, const bool isUpdatable) {
    const int headerFilePathBufSize = PATH_MAX + 1 /* terminator */;
    char headerFilePath[headerFilePathBufSize];//聲明一個(gè)空間
    getHeaderFilePathInDictDir(path, headerFilePathBufSize, headerFilePath);
    // Allocated buffer in MmapedBuffer::openBuffer() will be freed in the destructor of
    // MmappedBufferPtr if the instance has the responsibility.
    MmappedBuffer::MmappedBufferPtr mmappedBuffer =
            MmappedBuffer::openBuffer(headerFilePath, isUpdatable);
    if (!mmappedBuffer) {
        return nullptr;
    }
    const FormatUtils::FORMAT_VERSION formatVersion = FormatUtils::detectFormatVersion(
            mmappedBuffer->getReadOnlyByteArrayView());
    switch (formatVersion) {
        case FormatUtils::VERSION_2:
        case FormatUtils::VERSION_201:
        case FormatUtils::VERSION_202:
            AKLOGE("Given path is a directory but the format is version 2xx. path: %s", path);
            break;
        case FormatUtils::VERSION_402: {
            return newPolicyForV4Dict<backward::v402::Ver4DictConstants,
                    backward::v402::Ver4DictBuffers,
                    backward::v402::Ver4DictBuffers::Ver4DictBuffersPtr,
                    backward::v402::Ver4PatriciaTriePolicy>(
                            headerFilePath, formatVersion, std::move(mmappedBuffer));
        }
        case FormatUtils::VERSION_4_ONLY_FOR_TESTING:
        case FormatUtils::VERSION_403: {
            return newPolicyForV4Dict<Ver4DictConstants, Ver4DictBuffers,
                    Ver4DictBuffers::Ver4DictBuffersPtr, Ver4PatriciaTriePolicy>(
                            headerFilePath, formatVersion, std::move(mmappedBuffer));
        }
        default:
            AKLOGE("DICT: dictionary format is unknown, bad magic number. path: %s", path);
            break;
    }
    ASSERT(false);
    return nullptr;
}


-----------------------------------------------------------------------

/* static */ MmappedBuffer::MmappedBufferPtr MmappedBuffer::openBuffer(
        const char *const path, const int bufferOffset, const int bufferSize,
        const bool isUpdatable) {
    const int mmapFd = open(path, O_RDONLY);
    if (mmapFd < 0) {
        AKLOGE("DICT: Can't open the source. path=%s errno=%d", path, errno);
        return nullptr;
    }
    const int pagesize = sysconf(_SC_PAGESIZE);
    const int offset = bufferOffset % pagesize;
    int alignedOffset = bufferOffset - offset;
    int alignedSize = bufferSize + offset;
    const int protMode = isUpdatable ? PROT_READ | PROT_WRITE : PROT_READ;
    void *const mmappedBuffer = mmap(0, alignedSize, protMode, MAP_PRIVATE, mmapFd,
            alignedOffset);
        //1采盒、將一個(gè)普通文件映射到內(nèi)存中,通常在需要對(duì)文件進(jìn)行頻繁讀寫時(shí)使用蔚润,這樣用內(nèi)存讀寫取代I/O讀寫磅氨,以獲得較高的性能;
        //2嫡纠、將特殊文件進(jìn)行匿名內(nèi)存映射烦租,可以為關(guān)聯(lián)進(jìn)程提供共享內(nèi)存空間;
        //3除盏、為無關(guān)聯(lián)的進(jìn)程提供共享內(nèi)存空間叉橱,一般也是將一個(gè)普通文件映射到內(nèi)存中。
    if (mmappedBuffer == MAP_FAILED) {
        AKLOGE("DICT: Can't mmap dictionary. errno=%d", errno);
        close(mmapFd);
        return nullptr;
    }
    uint8_t *const buffer = static_cast<uint8_t *>(mmappedBuffer) + offset;
    if (!buffer) {
        AKLOGE("DICT: buffer is null");
        close(mmapFd);
        return nullptr;
    }
    return MmappedBufferPtr(new MmappedBuffer(buffer, bufferSize, mmappedBuffer, alignedSize,
            mmapFd, isUpdatable));
}



這塊的邏輯就是通過apk路徑者蠕,獲取dict文件窃祝。獲得

接下來我們來看第二難題,

可以看到openNative將Dictionary對(duì)象轉(zhuǎn)換成long類型踱侣,拿到Dictionary對(duì)象并能直接讀取到數(shù)據(jù)粪小,直接去看

/* displayWidth  鍵盤寬度 1080
 * displayHeight 鍵盤高度 667
 * gridWidth 網(wǎng)格寬度
 * gridHeight 網(wǎng)格高度
 * mostCommonkeyWidth  常用鍵寬度
 * mostCommonkeyHeight 常用鍵高度
 * proximityChars  int[]數(shù)組 長(zhǎng)度為[gridWidth*gridHeight*MAX_PROXIMITY_CHARS_SIZE] 再根據(jù)mGrideSize進(jìn)行數(shù)據(jù)填充
 * keyCount 鍵位數(shù)量 29
 * keyXCoordinates 鍵位對(duì)應(yīng)X坐標(biāo) int[]數(shù)組 長(zhǎng)度29
 * keyYCoordinates 鍵位對(duì)應(yīng)Y坐標(biāo) int[]數(shù)組 長(zhǎng)度29
 * keyWidths 鍵位寬度 int[]數(shù)組 長(zhǎng)度29
 * keyHeights 鍵位高度 int[]數(shù)組 長(zhǎng)度29
 * keyCharCodes 對(duì)應(yīng)Codes int[]數(shù)組 長(zhǎng)度29
 * sweetSpotCenterXs 最佳點(diǎn)擊區(qū)域X坐標(biāo)  float[]數(shù)組 長(zhǎng)度29
 * sweetSpotCenterYs 最佳點(diǎn)擊區(qū)域Y坐標(biāo)  float[]數(shù)組 長(zhǎng)度29
 * sweetSpotRadii 鍵位半徑 float[]數(shù)組 長(zhǎng)度29
 * */
static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jclass clazz,
        jint displayWidth, jint displayHeight, jint gridWidth, jint gridHeight,
        jint mostCommonkeyWidth, jint mostCommonkeyHeight, jintArray proximityChars, jint keyCount,
        jintArray keyXCoordinates, jintArray keyYCoordinates, jintArray keyWidths,
        jintArray keyHeights, jintArray keyCharCodes, jfloatArray sweetSpotCenterXs,
        jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) {
    ProximityInfo *proximityInfo = new ProximityInfo(env, displayWidth, displayHeight,
            gridWidth, gridHeight, mostCommonkeyWidth, mostCommonkeyHeight, proximityChars,
            keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
            sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
    return reinterpret_cast<jlong>(proximityInfo);
}
/* dict 通過openNative返回的dictionary對(duì)象值為long類型
 * ProximityInfo  通過調(diào)用setproximityInfoNative() 返回的ProximityInfo對(duì)象
 * dicTraverseSession  通過調(diào)用SetDicTraversesessionNative 傳入locale和dictsize 參數(shù)獲得
 * xCoordinatesArray 點(diǎn)擊鍵盤x坐標(biāo)位置 Int[]類型
 * yCoordinatesArray 點(diǎn)擊鍵盤y坐標(biāo)位置 Int[]類型
 * timeArray  int[]數(shù)組類型 暫不考慮
 * pointerIdsArray 參數(shù)和查詢無關(guān)
 * inputSize 將鍵入的單詞中代碼點(diǎn)復(fù)制到int目標(biāo)數(shù)組中
 * suggestOptions 主要篩選單詞類型,和查詢關(guān)系也不大
 * prevWordCodePointArrays 為空的二維數(shù)組
 * isBeginningOfSentenceArray boolean數(shù)組
 * prevWordCount 固定值3抡句,猜想是聯(lián)想詞個(gè)數(shù)探膊,結(jié)果發(fā)現(xiàn)不是
 * outSuggestionCount int[]長(zhǎng)度為1 值為0
 * outCodePointsArray int[]數(shù)組長(zhǎng)度為 48*18 unicode編碼
 * outScoresArray int[]數(shù)組 長(zhǎng)度為18
 * outSpaceIndicesArray int[]數(shù)組 長(zhǎng)度為18
 * outTypesArray int[]數(shù)組 長(zhǎng)度為18
 * outAutoCommitFirstWordConfidenceArray int[]數(shù)組 長(zhǎng)度為1
 * inOutWeightOfLangModelVsSpatialModel float[]數(shù)組 長(zhǎng)度為1
 * */
static void latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jclass clazz, jlong dict,
        jlong proximityInfo, jlong dicTraverseSession, jintArray xCoordinatesArray,
        jintArray yCoordinatesArray, jintArray timesArray, jintArray pointerIdsArray,
        jintArray inputCodePointsArray, jint inputSize, jintArray suggestOptions,
        jobjectArray prevWordCodePointArrays, jbooleanArray isBeginningOfSentenceArray,
        jint prevWordCount, jintArray outSuggestionCount, jintArray outCodePointsArray,
        jintArray outScoresArray, jintArray outSpaceIndicesArray, jintArray outTypesArray,
        jintArray outAutoCommitFirstWordConfidenceArray,
        jfloatArray inOutWeightOfLangModelVsSpatialModel) {
    Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);

    // Assign 0 to outSuggestionCount here in case of returning earlier in this method.
    LogUtils::logToJava(env, "this is a dictionary duixiang ");
    JniDataUtils::putIntToArray(env, outSuggestionCount, 0 /* index */, 0);
    if (!dictionary) {
        return;
    }
    ProximityInfo *pInfo = reinterpret_cast<ProximityInfo *>(proximityInfo);
    DicTraverseSession *traverseSession =
            reinterpret_cast<DicTraverseSession *>(dicTraverseSession);
    if (!traverseSession) {
        return;
    }
    // Input values
    int xCoordinates[inputSize];
    int yCoordinates[inputSize];
    int times[inputSize];
    int pointerIds[inputSize];
    const jsize inputCodePointsLength = env->GetArrayLength(inputCodePointsArray);
    int inputCodePoints[inputCodePointsLength];
    env->GetIntArrayRegion(xCoordinatesArray, 0, inputSize, xCoordinates);
    env->GetIntArrayRegion(yCoordinatesArray, 0, inputSize, yCoordinates);
    env->GetIntArrayRegion(timesArray, 0, inputSize, times);
    env->GetIntArrayRegion(pointerIdsArray, 0, inputSize, pointerIds);
    env->GetIntArrayRegion(inputCodePointsArray, 0, inputCodePointsLength, inputCodePoints);

    const jsize numberOfOptions = env->GetArrayLength(suggestOptions);
    int options[numberOfOptions];
    env->GetIntArrayRegion(suggestOptions, 0, numberOfOptions, options);
    SuggestOptions givenSuggestOptions(options, numberOfOptions);

    // Output values
    /* By the way, let's check the output array length here to make sure */
    const jsize outputCodePointsLength = env->GetArrayLength(outCodePointsArray);
    if (outputCodePointsLength != (MAX_WORD_LENGTH * MAX_RESULTS)) {
        AKLOGE("Invalid outputCodePointsLength: %d", outputCodePointsLength);
        ASSERT(false);
        return;
    }
    const jsize scoresLength = env->GetArrayLength(outScoresArray);
    if (scoresLength != MAX_RESULTS) {
        AKLOGE("Invalid scoresLength: %d", scoresLength);
        ASSERT(false);
        return;
    }
    const jsize outputAutoCommitFirstWordConfidenceLength =
            env->GetArrayLength(outAutoCommitFirstWordConfidenceArray);
    ASSERT(outputAutoCommitFirstWordConfidenceLength == 1);
    if (outputAutoCommitFirstWordConfidenceLength != 1) {
        // We only use the first result, as obviously we will only ever autocommit the first one
        AKLOGE("Invalid outputAutoCommitFirstWordConfidenceLength: %d",
                outputAutoCommitFirstWordConfidenceLength);
        ASSERT(false);
        return;
    }
    float weightOfLangModelVsSpatialModel;
    env->GetFloatArrayRegion(inOutWeightOfLangModelVsSpatialModel, 0, 1 /* len */,
            &weightOfLangModelVsSpatialModel);
    SuggestionResults suggestionResults(MAX_RESULTS);
    const NgramContext ngramContext = JniDataUtils::constructNgramContext(env,
            prevWordCodePointArrays, isBeginningOfSentenceArray, prevWordCount);
    if (givenSuggestOptions.isGesture() || inputSize > 0) {
        // TODO: Use SuggestionResults to return suggestions.
        dictionary->getSuggestions(pInfo, traverseSession, xCoordinates, yCoordinates,
                times, pointerIds, inputCodePoints, inputSize, &ngramContext,
                &givenSuggestOptions, weightOfLangModelVsSpatialModel, &suggestionResults);
    } else {
        dictionary->getPredictions(&ngramContext, &suggestionResults);
    }
    if (DEBUG_DICT) {
        suggestionResults.dumpSuggestions();
    }
    suggestionResults.outputSuggestions(env, outSuggestionCount, outCodePointsArray,
            outScoresArray, outSpaceIndicesArray, outTypesArray,
            outAutoCommitFirstWordConfidenceArray, inOutWeightOfLangModelVsSpatialModel);
}
//通過unicode 拿到word
new String(session.mOutputCodePoints, start, len)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市待榔,隨后出現(xiàn)的幾起案子逞壁,更是在濱河造成了極大的恐慌,老刑警劉巖锐锣,帶你破解...
    沈念sama閱讀 217,826評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件腌闯,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡雕憔,警方通過查閱死者的電腦和手機(jī)绑嘹,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,968評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來橘茉,“玉大人工腋,你說我怎么就攤上這事〕┳浚” “怎么了擅腰?”我有些...
    開封第一講書人閱讀 164,234評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)翁潘。 經(jīng)常有香客問我趁冈,道長(zhǎng),這世上最難降的妖魔是什么拜马? 我笑而不...
    開封第一講書人閱讀 58,562評(píng)論 1 293
  • 正文 為了忘掉前任渗勘,我火速辦了婚禮,結(jié)果婚禮上俩莽,老公的妹妹穿的比我還像新娘旺坠。我一直安慰自己,他們只是感情好扮超,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,611評(píng)論 6 392
  • 文/花漫 我一把揭開白布取刃。 她就那樣靜靜地躺著,像睡著了一般出刷。 火紅的嫁衣襯著肌膚如雪璧疗。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,482評(píng)論 1 302
  • 那天馁龟,我揣著相機(jī)與錄音崩侠,去河邊找鬼。 笑死坷檩,一個(gè)胖子當(dāng)著我的面吹牛却音,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播淌喻,決...
    沈念sama閱讀 40,271評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼僧家,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了裸删?” 一聲冷哼從身側(cè)響起八拱,我...
    開封第一講書人閱讀 39,166評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎涯塔,沒想到半個(gè)月后肌稻,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,608評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡匕荸,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,814評(píng)論 3 336
  • 正文 我和宋清朗相戀三年爹谭,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片榛搔。...
    茶點(diǎn)故事閱讀 39,926評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡诺凡,死狀恐怖东揣,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情腹泌,我是刑警寧澤嘶卧,帶...
    沈念sama閱讀 35,644評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站凉袱,受9級(jí)特大地震影響芥吟,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜专甩,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,249評(píng)論 3 329
  • 文/蒙蒙 一钟鸵、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧涤躲,春花似錦棺耍、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,866評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至缸托,卻和暖如春左敌,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背俐镐。 一陣腳步聲響...
    開封第一講書人閱讀 32,991評(píng)論 1 269
  • 我被黑心中介騙來泰國(guó)打工矫限, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人佩抹。 一個(gè)月前我還...
    沈念sama閱讀 48,063評(píng)論 3 370
  • 正文 我出身青樓叼风,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親棍苹。 傳聞我的和親對(duì)象是個(gè)殘疾皇子无宿,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,871評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容

  • Swift1> Swift和OC的區(qū)別1.1> Swift沒有地址/指針的概念1.2> 泛型1.3> 類型嚴(yán)謹(jǐn) 對(duì)...
    cosWriter閱讀 11,101評(píng)論 1 32
  • 1.ios高性能編程 (1).內(nèi)層 最小的內(nèi)層平均值和峰值(2).耗電量 高效的算法和數(shù)據(jù)結(jié)構(gòu)(3).初始化時(shí)...
    歐辰_OSR閱讀 29,385評(píng)論 8 265
  • 1、java中==和equals和hashCode的區(qū)別 基本數(shù)據(jù)類型的==比較的值相等.類的==比較的內(nèi)存的地址...
    快感的感知閱讀 1,140評(píng)論 0 4
  • 1枢里、java中==和equals和hashCode的區(qū)別 基本數(shù)據(jù)類型的==比較的值相等.類的==比較的內(nèi)存的地址...
    Mr_Fly閱讀 855評(píng)論 0 0
  • 大綱 Java 基礎(chǔ) 1. ==孽鸡、equals 和 hashCode 的區(qū)別 == 用于基礎(chǔ)數(shù)據(jù)類型的判斷時(shí),比較...
    Parallel_Lines閱讀 854評(píng)論 0 2