Is there any difference between delaring an array like
int[] array = new int[10];
and declaring it like
int array[] = new int[10];
?
Both are valid in Java but I havent found any differences (initialization or something?) or is it just two different ways to describe the same thing for the compiler?
Difference between “int[] a” and “int a[]” for 1-D Arrays in Java. For 1-D Array, in Java, there is no difference and any of the mentioned syntaxes can be used to declare a 1-D array.
There is no difference in these two types of array declaration. There is no such difference in between these two types of array declaration. It's just what you prefer to use, both are integer type arrays. There is no difference in functionality between both styles of declaration.
They have no difference, but that notational difference allows this identity:
int[] array; int[][] matrix;
===
int array[], matrix[][];
===
int[] array, matrix[];
Here is the related specification page: http://java.sun.com/docs/books/jls/third_edition/html/arrays.html#17235
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With