As others have pointed out: An array in Java is a rather "low-level" construct. Although it is an Object
, it is not really part the object-oriented world. This is true for arrays of references, like String[]
, but even more so for primitive arrays like int[]
or float[]
. These arrays are rather "raw, contiguous blocks of memory", that have a direct representation inside the Java Virtual Machine.
From the perspective of language design, arrays in Java might even be considered as a tribute to C and C++. There are languages that are purely object-oriented and where plain arrays or primitive types do not exist, but Java is not one of them.
More specifically focusing on your question:
An important point here is that Arrays#asList
does not do any conversion. It only creates List
that is a view on the array. In contrast to that, the Collection#toArray
method indeed creates a new array. I wrote a few words about the implications of this difference in this answer about the lists that are created with Arrays#asList
.
Additionally, the Arrays#asList
method only works for arrays where the elements are a reference type (like String[]
). It does not work for primitive arrays like long[]
*. But fortunately, there are several methods to cope with that, and I mentioned a few of them in this answer about how to convert primitive arrays into List
objects.
* In fact, Arrays#asList
does work for primitive arrays like long[]
, but it does not create a List<Long>
, but a List<long[]>
. That's often a source of confusion...