I have found this insertion example and I did not understand the goal of setting int i=26, rather than just doing a normal loop
public static void main(String[] args) {
int[] arr=new int[10];
arr[0]=1;
arr[1]=2;
arr[2]=5;
int n=3;
int capacity =10;
//what I did not understand is this declaration of i
int i,key=26;
System.out.println("before sorted");
for(i=0;i<n;i++){
System.out.println(arr[i]);
}
n=insert(arr,n,key,capacity);
System.out.println("after");
for(i=0;i<n;i++){
System.out.println(arr[i]);
}
}
public static int insert(int[] arr,int n,int key, int capacity){
if(n>=capacity) {
return n;
}
arr[n]=key;
return(n+1);
1