How to filter an array in Java?

后端 未结 7 995
小蘑菇
小蘑菇 2020-12-10 02:01

How can I filter an array in Java?

I have an array of objects, for example cars:

Class:

public class Car{
    public int doors;
    public Ca         


        
7条回答
  •  星月不相逢
    2020-12-10 02:50

    I can't see much wrong with your code. You could just stick with Vectors throughout though.

    You could simplify the second part (where you copy the matching items into the new array) using Vector.copyInto(Object[]).

提交回复
热议问题