I am trying to learn generics but it gives me an error when I try to compile this code. It says
<T>printScores(T[]) in ArrayTest cannot be applied to (int[])
printScores(testScores);
^
public class ArrayTest{
public static <T> void printScores(T[] scores){
for(T t : scores){
System.out.println(t);
}
}
public static void main(String[] args){
int[] testScores;
testScores = new int[4];
printScores(testScores);
}
}
I know that I have a local array that doesn't have anything in it yet so I don't know if that's the problem or not, but I am sure it will be down the road. If anyone can help me I would appreciate it very much, Thanks.
If you insist on saying "DUH", try to make a post that makes a little more sense