public class Test {
    public static void main(String[] args) {
        int[] arr = {2, 5, 6,7};
        change(arr);//这里会提示错误
    }

    public static <E> void change(E[] e) {
        for (int min = 0, max = e.length - 1; min < max; min++, max--) {
            E temp = e[min];
            e[min] = e[max];
            e[max] = temp;
        }
        for (E e1 : e
                ) {
            System.out.print(e1);
        }
    }
}

使用泛型方法参数报错
此时只需要将int修改为对应的包装类型Integer就好了使用泛型方法参数报错

相关文章:

  • 2021-11-05
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2022-02-22
  • 2021-10-30
  • 2022-12-23
猜你喜欢
  • 2022-02-26
  • 2021-12-21
  • 2021-09-15
  • 2021-11-21
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案