This is a simple programme for array in java. I want delete a number at user want but it is not working in my code, last two element is proper working but at the starting of element deleting is not working and i don't want to use of ArrayList in my code.delete one element at user want which is present in array.
import java.util.Scanner;
public class delete {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in=new Scanner(System.in);
        System.out.println("pls enter the size of an array:-->");
        int n=in.nextInt();
        int num[]=new int[n];
        for(int k=0;k<num.length;k++)
        {
            System.out.println("enter the value:--> "+(k+1));
            num[k]=in.nextInt();
        }
        System.out.println("Enter the number to be delete:-->");
        int m=in.nextInt();
        for(int p=0;p<num.length-1;p++)
        {
            if(m==num[p])
            {
                  num[p]=num[p+1];      
             }
        }
        for(int k=0;k<num.length-1;k++)
            System.out.println(num[k]);
    }
}
 
     
    