I’m trying to add functionality to the Arrays-class. In my project I use the (static) methods from Arrays and have some other methods that also handle array-conversion, sorting, etc…
I’m trying to add these to an object MyArrays that extends Arrays so I can go
MyArrays.toList(foo);
but also
MyArrays.myOwnFunction(bar);
but i’m not able to extend it because Arrays-contructor has private access.
I know it’s not really necessary, but now I know i’m unable to do it, I realy want to.
Is there any workaround for this?
thanks,
You can’t. And why would it matter whether you have the utility functions in one or in two classes? For the record – there is commons-lang’s
ArrayUtilsthat has additional utility methods.Technically, you can reimplement all methods in your utility class by simply calling the corresponding methods in
Arrays, but that’s unneeded.