猿问

判断一个数组是否包含一个值?

该怎么判断?


3157695297
浏览 1257回答 3
3回答

00小伙

Set<String> set = new HashSet<String>(Arrays.asList(arr));return set.contains(targetValue);刚好做面试题看到,希望可以帮到你,望采纳!

慕的地8582982

OUXAKAOFSDEDCVOILUUHNVDPKIRFMMSVLZFIIITANTUBXNRIFGWCOIJMOAFLITIQNNLOKNXQREUABKWMOXOVYOUKBHZDGQNTCJCAWZISWGKJADSUADDIHTSPCZVZPNDDLEVCPCZQZRHCOVCWCVFOXKRAABEAAXQQHSYYCBRRVVWPGFMCPHRKMGMFPFYLBBLOIUENDNFYBEYYBEEXFMDDXKKKQMSSUKDMCSWMJTTVROPFPPSFJVEQRBLLLHKKXSXTTVJHDKAKHKDZLFRUNAKVRXOYYYMBTUEDTTJJJMPMDXJTCFPVYURKBNYRSBSYURHDRKUHQHAGAHBXHQZQZVRUKXZBWLVSCYISXNDMKAWSVJNLHRZIKIQAWGBAAAWGFCSFOJPVFIEXNSCKMZBMIVFLGAEEYVYLUEUFZHNTZSISMPUSYQJCTXHSIHRUWBBEZTWMRSJSUEAQMCZOENFOKADGWNPAEVQTIEOKGCZJQGWZZRAKGTLPSIQNBYHXGYPQMCMCFUXMQLAKUQGORAQTRTBYOXGWFVLWMBRAQNKMWNZOFBXNPSVYMPXHKUWGCMVMTCYHPYBRGQULBJGQTVLNQTTPXCRCFOQHYPOPZCEXQQARXZVGQGPLOFVXUPSCXMWRBFWYOENWLVQAXBLOKUQSCEBKIFNEHXMUWZCUJFOSBXTWTPDFHEAWAPLCLFYIKAQNDZJLNWTCTWGJJZJMNQNCFIRNRVVQTCFOLUXOLZUQNDTWMZPMXUQZIZQMIFPBWMBRBKAPMCZWRODTDAPMKTSECBCSHGQXLVEAVYBXTPTLUQNQUXMCFPEXROHRKSOHNOPLCRODOQNJSOEUQMCSHQNWAOPKQASKBUJOFJABLXSTLTHSHQIQBPNI

coco49

楼上的方法可以用,或者是遍历数组,在遍历中使用 if(value.equals(arr[i]))来判断
随时随地看视频慕课网APP

相关分类

Java
我要回答