public static void main(String[] args) {
String[] strArr = new String[] { "0", "1", "2", "3", "4" };
// swap(strArr, 3, 4);
fanZhuan(strArr);
for (String string : strArr) {
System.out.print(string+" ");
}
}
public static <T> void swap(T[] t, int a, int b) {
T temp = t[a];
t[a] = t[b];
t[b] = temp;
}
public static <T> void fanZhuan(T[] t) {
for (int i = 0; i < t.length / 2; i++) {
swap(t,i,t.length-i-1);
}
}
|