|
There is a big difference between C++ and Java in how array arguments are passed to functions. In C++, it is not possible to pass an array by value; an argument of type T[] is converted to a T* when passed to a function. Since only a pointer to the array is passed, the size of the array is not available to the called function. For C-style strings that is not a problem, since the size of the array of characters can be determined locally by looking for the null terminating character. For other arrays, however, it becomes necessary to use an additional argument for specifying the size of the array.
In Java, an array is passed to a function like any other object. As was mentioned earlier in Section 7.10, a Java array is a class type object.
|