Note that there are some explanatory texts on larger screens.

plurals
  1. USgrAPPfruit
    primarykey
    data
    text
    plurals
    1. COThe exception: (copy & paste) `java.lang.InstantiationException: generics.MyClass` `at java.lang.Class.newInstance0(Unknown Source)` `at java.lang.Class.newInstance(Unknown Source)` `at generics.CoolArray.<init>(CoolArray.java:14)` `at generics.CoolArrayTest.create(CoolArrayTest.java:12)` `at generics.CoolArrayTest.main(CoolArrayTest.java:6)` I couldn't get anything from that :)
      singulars
    2. COI am really grateful for your enthusiasm towards solving my problem! But I just posted the solution to my problem myself. You are right again, i meant `InstantiationException` and it looked like `java.lang.InstantiationException: generics.MyClass`. It pointed to the line where I call `array[ i ] = clazz.newInstance();` That's why I figured that there must be something wrong in that line but it was the constructor of my class that led to that error. My detailed explanation below should leave no questions.
      singulars
    3. COThank you for your answer! Well, you are not correct with the ArrayList part. I didn't want to use ArrayLists because of the performance issue when inserting and removing elements. Especially when called multiple times each frame from *update()* and *render()*. Well, I didn't mean I solved the `NullPointerException` I just wanted to know what I have to write there to make it work. You are absolutely right, it is `array[i].newInstance()`. But when I wrote that, I got an `InstantiationError`. That is the one I wanted to get fixed.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload