How do I remove objects from an array in Java?
问题 Given an array of n Objects, let\'s say it is an array of strings , and it has the following values: foo[0] = \"a\"; foo[1] = \"cc\"; foo[2] = \"a\"; foo[3] = \"dd\"; What do I have to do to delete/remove all the strings/objects equal to \"a\" in the array? 回答1: [If you want some ready-to-use code, please scroll to my "Edit3" (after the cut). The rest is here for posterity.] To flesh out Dustman's idea: List<String> list = new ArrayList<String>(Arrays.asList(array)); list.removeAll(Arrays