I have
out.load(output, transactions, columnHeaders, dataFormat);
Where load
is defined as:
public boolean load(String outputfile, List<Transaction> transactions, List<String> columnHeaders, String dataFormat);
and
String output = "";
String dataFormat = "";
ArrayList<ARTransaction> transactions = new ArrayList<ARTransaction>();
List<String> columnHeaders = null;
where
ARTransaction implements Transaction
Why is there a problem on the type of transactions
?
public boolean load(String outputfile, List<? extends Transaction> transactions, List<String> columnHeaders, String dataFormat);
Or just declare transactions as a List<Transaction>
.
Here's the common example of why you obviously can't do this:
List<String> list = new ArrayList<String>();
List<Object> objList = list; //if this were possible
objList.add(Integer.valueOf(5));
String val = list.get(0); //ClassCastException here
System.out.println(val);
It is having difficulties casting the contravariant type that is from ArrayList<ARTransaction>
to List<Transaction>
.
Try List<? extends Transaction>
instead
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