Prev Next

Java / Arrays

Difference between int array[] and int[] array.

There is no difference between array[] and []array. Both array[] and []array are the ways to declare an array. The only difference between them is that if we are declaring more than one array in a line, we should use prefix []. If we are declaring a single array in a line, we should use postfix []. For example, consider the following declaration

int array1[], var1;   //array1[] is an array while var1 is just a variable of type int  
int[] arr1, arr2;  //both arr1 and arr2 are arrays of int type  

More Related questions...

Show more question and Answers...


Comments & Discussions