- public class GenericDemo{
- public static void main(String[] args){
- Integer []arr = {1,2,3,4};
- demo(arr,0,3);//这个错哪了、、、
- for(int i : arr)
- {
- System.out.println(i);
- }
- }
-
- public static <T> void demo(T[] arr,int x,int y)
- {
- T temp = arr[x];
- arr[x] = arr[y];
- arr[y] = temp;
- }
-
- }
复制代码 应该是这样子的,int []是Object对象,int [][]才是Object[] |