Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java remove element at position from array and shift

static void deleteStudent() {
    System.out.println("Which student would you like to delete?"); //fixed spelling error
    for(int i=0;i<9;i++) {
      System.out.println(i + ": " + studentNamesArray[i]);
    }
    int studentChoice = input.nextInt();
    StudentName[] temp = new StudentName[studentNamesArray.length];//I don't know format
    for(int i = 0; i<studentNamesArray.length; i++) {
        if(i != studentChoice)
        {
            temp[j] = studentNamesArray[i]
         
        }
    }
    temp[studentNamesArray.length-1] = null;
    studentNamesArray = temp;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Java #remove #element #position #array #shift
ADD COMMENT
Topic
Name
5+8 =