Skip to main content

Question about array defination

2 replies [Last post]
hooked
Offline
Joined: 2010-01-14

hello
i would like to know whats the difference between:
private int[] sources; // sources ids
private Vertex vertexes[]; // array of the vertexes in the graph

sources is an array if integers?
vertexes is an array of vertexes ?

then why writing the [] in the different locations.

thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
peter__lawrey
Offline
Joined: 2005-11-01

The first line shows the type which is int[] in one place and is preferred by many. The second is for backward compatibility with C which uses this notation.

To really confuse you can use

private int[] sources[];

anthony_p
Offline
Joined: 2006-07-24

There's absolutely no difference. You're free to place the brackets where you want when declaring an array.