0

I am trying to create an array of a specific Data Type, however I am getting a Type Safety error I cannot understand/solve.

The data type

private static class Component<F> {

    private int index;
    private F value;

    public Component(int index, F value) {
        this.index = index;
        this.value = value;
    }

And the code where I try to initialize the array

private Component<F>[] table;

// Constructor
public SparseVector(int n, F f) {
    table = new Component[n];       
}

However I get the said type safety error, and upon running the program inspecting the variables in debugging I get the message "Type has not been loaded occurred while retrieving component type of array."

JPinto
  • 1
  • What debugger gives you that message? – Radiodef May 23 '15 at 18:23
  • Warning is little different than error. Anyway general rule is that arrays are generics don't mix well so you should avoid combining them. Instead of `Component[]` array use collection like `List>`. – Pshemo May 23 '15 at 18:26
  • @Pshemo I have seen that suggestion in other similar questions to mine, however it was requested that I use an array. – JPinto May 23 '15 at 18:47

0 Answers0