Java template class that takes an array; any way to enforce that? -
I am writing a template class that should keep an array in its form.
Public squares foo & lt; T & gt; {...}
How can I do the best that "T" is an array type? (Int [], bar [], ...) Probably compile the time if possible, obviously, but otherwise the best way to debug is to throw an exception, either T is not an array?
It is not possible to do this properly how you have said and the normal type is specified in array or primitive Please.
Syntax allows such things to be:
public square fu & lt; Az09 $ _ Expands MyClassOrInterface & amp; Serial & amp; Closeable & gt; {...}
Where az09 $ _ is a valid identifier, which can also be parameterized with evenly formatted normal type.
But az09 $ _ is restricted as being a Java identifier, so that you can see the public class Foo & lt; T []> {...}
Anything you can do
Typically you can use the t, i.e.:
public square fu & lt; T & gt; {Public T [] Process This (T ... ts) {// Return Some; }}
Comments
Post a Comment