Shorten array length once element is remove in Java

前端 未结 5 1741
庸人自扰
庸人自扰 2021-01-13 10:00

Note: Following is my homework/assignment, feel free not to answer if you will.

I want to delete/remove an element from an String array(Set) basic, I\'m not allowe

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-13 10:56

    Basically you need to create a new array which is as long as the old array's length minus 1 and then you need to copy the valid elements from the old to the new array in a loop and then replace the old array with the new array.

    Since this is homework, details are left away. Feel free to post a comment for a bit more clarification.

提交回复
热议问题