Here is my code:
public class MyClass<A, B> {
ArrayList<A> arrayA;
ArrayList<B[]> arrayB;
...// other methods
public void put(A a, B b) {
//in case 'a' does not exist in arrayA, I want to create new array in arrayB (generic array)
B[] temp = new B[]();
//add some item here
arrayB.add(temp)
}
}
This doesn't work and I don't know why. Initialization of new array B[] gives compile error. What's the way I could fix this? Or how could I go around this?