Java数组到特定位置


Java数组到特定位置

import java.util.Arrays;

public class ChangingPositions {

   public static void main(String args[]) {

      int originalPosition = 1;

      int newPosition = 1;

      int [] myArray = {23, 93, 56, 92, 39};

      int temp = myArray[originalPosition];



      myArray[originalPosition] = myArray[newPosition];

      myArray[newPosition] = temp;

      System.out.println(Arrays.toString(myArray));

   }

}