考虑以下代码段
int key1 = Arrays.asList(new int[]{1,2,3,4,5}).indexOf(5) ;//wrapper
int key2 = new ArrayList<>(Arrays.asList(new int[]{1,2,3,4,5})).indexOf(5); //another copy
但是此代码段的计算结果为 -1 -1,这意味着它没有在列表中找到键 5。但是为什么Arrays.aslist不在列表中找到密钥。任何人都可以在没有明确逻辑实现的情况下解释或快速修复在数组中搜索键的代码。当然,我们可以对其进行排序,然后使用Arrays.binarySearch. 任何其他建议或任何其他方式来做到这一点。