2

Is there any difference in declaring array argument in java like:

public void method(Type[] arg) { ... } 

and in that way:

public void method(Type arg[]) { ... } 

Just curiosity...

Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143

2 Answers2

2

It is better practice to place them after the type, it is for understanding purposes. Also note that:

String[] firstArray[], secondArray;

Here you have firstArray variable referring to a two dimensional array and secondArray variable refering to an one dimension array;

ddarellis
  • 3,912
  • 3
  • 25
  • 53
1

No difference.

In SCJP Sun Certified Programmer for Java 6:

When declaring an array reference, you should always put the array brackets immediately after the declared type, rather than after the identifier (variable name). That way, anyone reading the code can easily tell that, for example, key is a reference to an int array object, and not an int primitive.

Anarki
  • 373
  • 5
  • 20