使用泛型方法参数报错

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);
        }
    }
}

猜你喜欢

转载自blog.csdn.net/aoyuzeng/article/details/84849544