I don't understand the error of Generic Array Creation.
First I tried the following:
public PCB[] getAll() {
PCB[] res = new PCB[list.size()];
for (int i = 0; i < res.length; i++) {
res[i] = list.get(i);
}
list.clear();
return res;
}
Then I tried doing this:
PCB[] res = new PCB[100];
I must be missing something cause that seems right. I tried looking it up I really did. And nothing is clicking.
My question is: What can I do to fix this?
the error is :
.\Queue.java:26: generic array creation
PCB[] res = new PCB[200];
^
Note: U:\Senior Year\CS451- file
uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Tool completed with exit code 1
PCB
is a generic type parameter and thus, what you are doing is impossible in Java due to type-erasure. If that is all true, you should click on the link I marked this a dup of as it provides a workaround.PCB
actually has no meaning at runtime (or technically, it does, but it's probably justObject
which wouldn't do you any good). There are two ways to circumvent this restriction. Both are explained in detail at the link I referenced. Let me know what specific part of that solution you are having trouble with.