Here you can find the source of swapPerTowElement(int[] arr)
private static void swapPerTowElement(int[] arr)
//package com.java2s; //License from project: Open Source License public class Main { private static void swapPerTowElement(int[] arr) { int len = arr.length; for (int i = 1; i < len; i += 2) { swap(arr, i, i - 1);//from w w w. j av a 2s.co m } } private static void swap(int[] arr, int i, int j) { int t = arr[i]; arr[i] = arr[j]; arr[j] = t; } }