Import Java.util.scanner;public class Tenth {/* has n integers so that it moves backward in the first order of M positions, and the last m number becomes the first m number */public static void main (string[] args) {Scanner input=new Scanner (system.in); System.out.println ("You will enter the number of numbers:"); int a=input.nextint (); int[] Array=new int[a];int t,i; System.out.println ("The number of digits you want to Exchange is:"); int b=input.nextint (); SYSTEM.OUT.PRINTLN ("Please input array:"); for (i=0;i<a;i++) array[i]=input.nextint (); SYSTEM.OUT.PRINTLN ("Array before Interchange is:"), for (i=0;i<a;i++) System.out.print (array[i]+ ""), for (i=0;i<b;i++) {T=array[i] ; array[i]=array[array.length-b+i];array[array.length-b+i]=t;} System.out.println ("\ n" + "After Interchange array is:"); for (i=0;i<a;i++) System.out.print (array[i]+ "");}}
Java Basics Exercise 10