Please see the code below.
The task is to make the code which replaces element inserted by the user and for replacement only for-statement can be used (this is the task requirement). The rest of the elements are to be saved. E.g. when input is "1" the following output is expected "0 2 3 4"
Please help with modification of for-statement following after line "System.out.println("The following element to de deleted "+removedElement);".
If it is possible please advise on both options when "<" and ">" symbols can be used.
import java.util.Scanner;
public class MainClass {
public static void main(String[] args) {
int baseArray [] = {0, 1, 2, 3, 4};
System.out.println("Existing array:");
for(int i = 0; i < baseArray.length; i++){
System.out.println(baseArray[i]);
}
System.out.println("Please indicate number of element to be deleted");
Scanner scr = new Scanner (System.in);
int removedElement = scr.nextInt();
System.out.println("The following element to de deleted "+removedElement);
for (int i = baseArray.length; i>removedElement; i--){
**baseArray[i]=baseArray[i];**
}
scr.close();
for(int i = 0; i < baseArray.length-1; i++){
System.out.println(baseArray[i]);
}
}
}