Java Generics and numbers

后端 未结 11 1141
离开以前
离开以前 2021-02-05 08:58

In an attempt to see if I can clean up some of my math code, mostly matrix stuff, I am trying to use some Java Generics. I have the following method:

private <         


        
11条回答
  •  Happy的楠姐
    2021-02-05 09:30

    Java's use of erasure to implement generics means that you're going to have trouble new'ing a generic type.

    How about using null to represent 0

    retVal[i][j] = null;
    

    You can then assign any type you want to the array later on.

提交回复
热议问题