function call error
Hey, I am trying to call a function
printTable(table); (where table is of type List<List<Double>>)
The function declaration is
public static void printTable(List<List<?>> c)
Netbeans shows that there is something wrong and when I try to compile it gives the following error:
printTable(java.util.List<java.util.List<?>>) in javaapplication1.TableIO cannot be applied to (java.util.List<java.util.List<java.lang.Double>>)
I guess I might have used the wildcard incorrectly. Any ideas?
What do you really want to do? Why are you using java.util.List<java.util.List<?>> ?
Hey, thanks for the pdf, I've only been reading up on this and collections for 2 days and I've obviously missed some details.
I checked the generic methods section and changed the function declaration to the following and it works now.
public static <T> void printTable(List<List<T>> c)
'table' is basically a (2d) table of values, in this case numbers. The function prints out the contents of the table in a way so it kind of looks like a table. I want to be able to use the function for tables of strings as well so I thought I should use a wildcard in the input parameter, which didn't end up working (although I'm still not sure why).
If you have anything to add, I'll still be here.