it works properly but when i enter value which is more then 5 it gives exception but not giving me output. If i enter 12 then output should be like this ( 4 , 5 , 1 , 2 , 3)
public static void main(String args[]) {
int[] a = { 1 , 2 , 3 , 4 , 5 };
int[] b = new int[5];
int j = 0,m = 0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter n:");
int n = sc.nextInt();
sc.nextLine();
m = n;
for(int i = n ; i < 5 ; i++) {
b[j] = a[i] - n;
System.out.println("" +b[j]);
j++;
}
for(int i = 0 ; i < n ; i++) {
b[j] = a[i] - a[i];
j++;
}
for(int k = 0 ; k < 5 ; k++) {
System.out.println("a["+k+"]:" +b[k]);
}