Java Generics and numbers

后端 未结 11 982
离开以前
离开以前 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条回答
  •  心在旅途
    2021-02-05 09:35

    Ye olde (reference) arrays do not play well with generics. In this case arrays are also likely to be inefficient. You are creating an array of arrays, so there is unnecessary indirection and bounds checking. Better to make a class Matrix. You may also want to add to the Matrix an reference to an instance of T that represents a zero.

提交回复
热议问题