tags:

views:

128

answers:

3

Just noticed in ByteArrayOutputStream, the toByteArray() is declared as,

public synchronized byte toByteArray()[];

What's the difference between this declaration and the following one?

public synchronized byte[] toByteArray();
+3  A: 

In this case, none.

If you had declarations:

byte[] a, b;
byte c[], d;

then a, b, and c are byte[], and d is byte.

Chris Jester-Young
+3  A: 

There is no difference, though convention amongst programmers strongly prefers the latter.

bkail
A: 

Java coding conventions document recommends the second variant (byte[] b). See example.

Roman