0

While reading the String class in java I noticed a weird constructor declaration

public String(byte bytes[], int offset, int length, String charsetName)

notice that the array bytes is declared as byte bytes[] instead of byte[] bytes

is there a difference between the two declarations? the java documentation never mention such possibility..

bennyl
  • 2,886
  • 2
  • 29
  • 43
  • I guess `byte bytes[]` is prefered by a lot of C developers, since they are using it there, but you should stick to `byte[] bytes` since this is the more common way to declare arrays in Java. – Tom Aug 27 '15 at 18:05
  • study shows that only serial killers do `byte bytes[]` – ZhongYu Aug 27 '15 at 18:39
  • @bayou.io another study shows that exaggaration rarely communicates what you really wanted to say – Durandal Aug 27 '15 at 18:45
  • @Durandal - every study shows that some people have no sense of humor :) – ZhongYu Aug 27 '15 at 18:47

2 Answers2

2

There is no difference. It just syntactic sugar in array declaration. Matter of taste. You can use any.

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
0

No difference. You can declare arrays either way

SacJn
  • 777
  • 1
  • 6
  • 16