Java Array Swap swap(final String a[], final int i, final int j)

Here you can find the source of swap(final String a[], final int i, final int j)

Description

Swaps two Strings.

License

Open Source License

Parameter

Parameter Description
a The array to be swapped
i First String index
j Second String index

Declaration


public static void swap(final String a[], final int i, final int j) 

Method Source Code

//package com.java2s;
/*//from   w w w  .  ja  v  a 2s  .c o m
 * 20:25:20 20/05/99
 *
 * The Java Shell: Utilities.
 * (C)1999 Romain Guy, Osvaldo Pinali Doederlein.
 *
 * LICENSE
 * =======
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * CHANGES
 * =======
 * 1.0.8 - Filled the listRoots method                   (Romain & Osvaldo)
 * 1.0.7 - Several bug fixes in constructPath            (Romain)
 * 1.0.6 - Split JDK1.1/1.2                              (Osvaldo)
 * 1.0.5 - Important bug fix in constructPath(String)    (Romain)
 * 1.0.4 - Added getSize(Enumeration)                    (Osvaldo)
 * 1.0.3 - Changed sortStrings bubble-sort algorithm to  (Romain)
 *         quick-sort (James Gosling)
 * 1.0.2 - Fixed two little bug in constructPath(String) (Romain)
 * 1.0.1 - Added listFiles(String[], boolean)            (Romain)
 *       - Removed unecessary createWhiteSpace(int)      (Romain)
 *       - Modified getWildCardMatches(String, boolean)  (Romain)
 *       - Slighty improved javadoc comments             (Romain)
 * 1.0.0 - Initial release.                              (Romain & Osvaldo)
 *
 * LINKS
 * =====
 * Contact: mailto@osvaldo.visionnaire.com.br
 * Site #1: http://www.geocities.com/ResearchTriangle/Node/2005/
 * Site #2: http://student.vub.ac.be/~opinalid/
 */

public class Main {
    /**
     * Swaps two Strings.
     *
     * @param a
     *                The array to be swapped
     * @param i
     *                First String index
     * @param j
     *                Second String index
     */

    public static void swap(final String a[], final int i, final int j) {
        String T;
        T = a[i];
        a[i] = a[j];
        a[j] = T;
    }
}

Related

  1. swap(final Object[] array, final int i, final int j)
  2. swap(final Object[] array, int offset1, int offset2)
  3. swap(final Object[] array, int pos)
  4. swap(final Object[] data, final int i, final int j)
  5. swap(final Object[] values, final int firstPosition, final int secondPosition)
  6. swap(final T[] arr, final int i, final int j)
  7. swap(final T[] arr, final int i, final int j)
  8. swap(int arr[], int i, int j)
  9. swap(int array[], int first, int last)