集册 Java实例教程 反转数组。

反转数组。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

494
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
反转数组。

/**

 * Copyright (C) 2011 NetMind Consulting Bt.

 *

 * This library is free software; you can redistribute it and/or

 * modify it under the terms of the GNU Lesser General Public

 * License as published by the Free Software Foundation; either

 * version 3 of the License, or (at your option) any later version.

 *

 * This library is distributed in the hope that it will be useful,

 * but WITHOUT ANY WARRANTY; without even the implied warranty of

 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

 * Lesser General Public License for more details.

 *

 * You should have received a copy of the GNU Lesser General Public

 * License along with this library; if not, write to the Free Software

 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 */

//package com.nowjava;


public class Main {// 来自 nowjava.com

    public static void main(String[] argv) throws Exception {

        byte[] b = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };

        System.out.println(java.util.Arrays.toString(reverse(b)));

    }


    /**

     * Reverse an array.

     */

    public static byte[] reverse(byte[] b) {

        
展开阅读全文