public
void
sortArray(
int
[] targetArr) {
long
t = System.currentTimeMillis();
Arrays.sort(targetArr);
System.out.println(
"执行时间:"
+ (System.currentTimeMillis() - t) +
"毫秒"
);
System.out.println(
"排序后结果"
);
for
(
int
i : targetArr){
System.out.print(i +
","
);
}
}
public
void
sort(
int
[] targetArr) {
long
t = System.currentTimeMillis();
int
temp =
0
;
for
(
int
i =
0
; i < targetArr.length; i++) {
for
(
int
j = i; j < targetArr.length; j++) {
if
(targetArr[i] > targetArr[j]) {
targetArr[i] = targetArr[i] ^ targetArr[j];
targetArr[j] = targetArr[i] ^ targetArr[j];
targetArr[i] = targetArr[i] ^ targetArr[j];
}
}
}
System.out.println(
"执行时间:"
+ (System.currentTimeMillis() - t) +
"毫秒"
);
System.out.println(
"排序后结果"
);
for
(
int
i : targetArr){
System.out.print(i +
","
);
}
}