日期:2014-05-20 浏览次数:20918 次
public class Demo1 {
public <T> void swap(T arr[], int pos1, int pos2) {
T temp = arr[pos1];
arr[pos1] = arr[pos2];
arr[pos2] = temp;
}
}
public class TestDemo {
@Test
public void test1() {
int intArr[] = new int[] { 12, 13, 15, 14 };
Demo1 d = new Demo1();
d.swap(intArr, 1, 2);
}
}