最近在网上看到一个问题,情况类似如下(记为问题1):
public class Demo { public static void main(String[] args) { System.out.println(testInteger(1)); System.out.println(testInt(1)); } public static boolean testInteger (Integer num) { Integer[] nums = new Integer[]{1, 2, 3, 4, 5, 6}; boolean flag = Arrays.asList(nums).contains(num); return flag; } public static boolean testInt (int num) { int[] nums = new int[]{1, 2, 3, 4, 5, 6}; boolean flag = Arrays.asList(nums).contains(num); return flag; } }