想问一下这段代码错哪了,正确的该怎么写😭
package k;
import java.util.Scanner;
public class abc {
public static void main(String args[]) {
int arr[]= {1,2,4,5,6};
System.out.println("请输入一个数:");
Scanner cin = new Scanner(System.in);
int m = cin.nextInt();
int end=arr[4];
int newarr[]=new int[5];
if(m>end)newarr[5]=m;
else {
for(int i=0;i<5;i++)
{
if(arr[i]>m) {
int temp1= arr[i];
newarr[i]=m;
for(int j=i+1;j<6;j++)
{
int temp2=arr[j];
newarr[j]=temp1;
temp1=temp2;
};
newarr[i]=arr[i];
break;
}
}
}
System.out.println(newarr);
}
}