Sign in to follow this  
Stuart_Mastrgamr

declaring an Array in Java

Recommended Posts

when you declare an array it's common to use this convention"

[code]int[] var = new int[10]; //bracket in front of the type[/code]


I just found out another way that compiles fine, but I dont know the difference:

[code]int var[] = new int[10]; //brackets in front of the varable instead of the type[/code]


What's the difference between the two?

Share this post


Link to post
Share on other sites
As a side note, if you're planning on writing portable code, avoid using the word "var" as a symbol.

In C# and JScript, said word is used to declare a variable, type of which gets implicitly determined by its initial assigned value (as opposed to manually typing the declaration).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this