C language and Java are a bit different when using arrays as parameters

C language and Java are a bit different when using arrays as parameters.

C `
void jh(int n[2]) {/Note that the parameter here is the size
int temp;
temp = n[0];
n[0] = n[1];
n[1] = temp;
}
int main() { int i; int num[2] = {7, 8}; jh(num); } Java




Insert picture description here
Since the array format defined in C and Java is slightly different, the parameter format here is also different. There is no need to give the size of the array as a parameter in Java.

Guess you like

Origin blog.csdn.net/publicstaticfinal/article/details/90240687