I\'m a programming beginner and I have question regarding a return value from a function.
I´m studying Java.
I have attached code from my book that features a cl
The sort()
method modifies the array passed as an argument; that is, the original array is modified.
Say you have array a
which value is [ 3, 2 ]
; you call sort(a)
; if your code looks like:
// printArray is an hypothetical method
printArray(a);
sort(a);
printArray(a);
then the output would be:
[3, 2]
[2, 3]
As a result there is no need for sort()
to return a result at all.
You can however modify the sort()
method to make a copy of the array, sort the copy and return that copy.