反转数组(与字符串反转的实现相同
//package com.nowjava; public class Main {/** 时代Java公众号 提 供 **/ /** * Reverses an array (Same implementation as string reversal * @param list */ public static void reverseArray(Character[] list) { reverseArrayFromToPosition(list, 0, list.length - 1); } public static void reverseArrayFromToPosition(Character[] list, int fromPos, int toPos) { //System.out.println("from Pos: " + fromPos + " to Pos" + toPos); int numIterations = (int) Math.ceil((toPos - fromPos) / 2.0); for (int x = fromPos; x < fromPos + numIterations; x++) { /* N o w J a v a . c o