i am having problem with a constructor that takes an arrayList as one of the arguments.
public class ItemisedProductLine extends ProductLine{
public static ArrayList<String> serialNumbers;
public ItemisedProductLine(String productCode, double recRetPrice, double salePrice, int quantity, String description, ArrayList<String> SerialNumbers){
super( productCode, recRetPrice, salePrice, quantity, description);
this.serialNumbers = serialNumbers;
}
}
Now in my class Inventory i want to instantiate a new ItemisedProductLine and pass an arryList of serial number to the constructor
ItemisedProductLine item = new ItemisedProductLine("productCode", 2600, 2490, 2, "descrpition", new ArrayList<String>("1233456", "6789123"));
Is this possible in Java? It seem to be not a common task to do, did not found any example.
As alternative i could have used an generic array instead of Array-List but then i can not initialize it because of the unknown size
Let's hope i'm not forgetting another parenthesis :-)
Last Thing is the error is "no suitable constructor found ArraList<>"
You could try:
new ArrayList<String>(Arrays.asList("1233456", "6789123"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With