   [java] Generic matrices
  Hi Guys,I want to be able to instanciate a matrix using any number type using generics. However, I want to store my matrix elements in an array but java 6 will not permit me to write;T matrixElements[] = new T[16];Im using JOGL as my graphics API so I want to be able to pass matrixElements[] to JOGL functions.Any1 have any advise, maybe some other way of doing this?Cheers   
Try this - http://www.ibm.com/developerworks/java/library/j-jtp01255.html   ;  Java generics are useless, especially for things like that. It also can't be done.There has been a lot of criticism with regard to them, but there's very little hope Sun will ever get around to making them useful.Right now, they're just fancy type-casting mechanism.For matrix, you can simply forget doing that. Each of your matrix elements will need to be an object, and boxed primitive types are immutable. Each time you perform any operation between two elements, you'll need to allocate new result.Overall, generics in Java are an unfortunate bastard child of trying to cater to everything, and delivering nothing. But yea, using your List no longer requires you cast the results.They're just syntactic sugar, with no real benefits to language itself.   