How do I remove objects from an array in Java?

前端 未结 20 1370
Happy的楠姐
Happy的楠姐 2020-11-22 01:20

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]          


        
20条回答
  •  抹茶落季
    2020-11-22 01:52

    Arrgh, I can't get the code to show up correctly. Sorry, I got it working. Sorry again, I don't think I read the question properly.

    String  foo[] = {"a","cc","a","dd"},
    remove = "a";
    boolean gaps[] = new boolean[foo.length];
    int newlength = 0;
    
    for (int c = 0; c

提交回复
热议问题