I would like to know how constructors with variable arguments work. Here is an example :
import java.util.ArrayList;
import java.util.List;
public class VehicleCompany {
private List<Vehicle> vehicles= new ArrayList<Vehicle>();
private void VehicleCompany (Vehicle... vehicles) {
//how to complete it?
}
Which way is the easier to do it? I found that I can copy the argumenttaxis
into another list
or use a for-loop
but didn't how to do since this.taxis.size()
is 0.
Any suggestions? Thanks!