Since the equals function in array only check the instance, it doesn’t work well with Set.
Hence, I wonder how to make a set of arrays in Java?
One possible way could be put each array in an object, and implement equals function for that class, but will that decrease the performance too much?
Since the ArrayList class already wraps an array, you can extend it and override the
equalsandhashCodemethods. Here is a sample:UPDATE:
You can even override it for a generic use, just changing the code to: