I have a numeric program in Java that does a lot of operations on primitive arrays. I use primitive arrays (
int) because they are much more memory and time-efficient than dealing with arrays of pointers to values (e.g.
Now, I want to be able to change my primitive type, eg. from double to float, based on some parameter to my program. But since primitive can not be used as generics, I can't for the life of me figure out how.
Is there any way, or is the vast amount of code replication or casting I have to do just an unavoidable flaw of Java?