The meaning of compareTo on an array depends on your use case. Thus it is not implemented in java.util.Arrays and because not every array contains comparable objects..
If you want to implement a compareTo Method on an array you have to answer the question:
When is one array less than, equal to or greater than another array?
If the array is a byte[] that is based on an ascii string it might be easy, but then you have a special use case.
Take a look at these questions to understand what I mean:
- How would you compare an array of
Comparables when you don't know much more about the elements than that they are Comparables?
- What kind of information do you get if you know that one array of
Comparables is less than another array of Comparables because each element at the same index is less than the other array's element at the same index and what would you do with such information?
- What would be the information that you will get if you compare the binary representation of 2 executable files?
I think that the byte[] is a very specific use case, becuse you think of the byte[] as a string of ascii characters, but remember that the byte[] representation of a string depends of the encoding.
compareTois when applied to an array.static int compareTo(byte[] a, byte[] b)