There is an array consisting of 5 characters like this ["1","2","3","4","5"] How to delete an element with an index of 3 so that the output would not be 1,2,3,4,5 , like this 1,2,3,5 ?

 List list = Arrays.asList(ar1.length); ArrayList<Map<String, Object>> date = new ArrayList<Map<String, Object>>(list); date.remove(8); Map<String, Object> map; for (int i = 0; i < list; i++) { map = new HashMap<String, Object>(); map.put("hour", ar1[i]); map.put("min",ar[i]); date.add(map); } 

Help selects the sheet in a loop

    2 answers 2

    The number of elements in the array is not edited (only through the re-creation of the array).

    But you can cast an Array to an ArrayList and cut an unnecessary element:

     List list = Arrays.asList(array); ArrayList<Integer> arraylist = new ArrayList<>(list); arraylist.remove(3); 

      The java array has a constant size. Nothing can be removed from it, nothing can be added.
      You can only create a new array and copy from the old only necessary.
      So do this for a change using the Stream API:

       String[] a = {"1", "2", "3", "4", "5"}; int removeIndex = 3; a = Stream.concat( // Объединить Arrays.stream(a).limit(removeIndex), // элементы до удаляемого Arrays.stream(a).skip(removeIndex+1) // элементы после удаляемого ).toArray(String[]::new); // в новый массив System.out.print(Arrays.toString(a));