aspose file tools*
The moose likes Beginning Java and the fly likes what is the difference between String[] args and String args[] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is the difference between String[] args and String args[]" Watch "what is the difference between String[] args and String args[]" New topic
Author

what is the difference between String[] args and String args[]

Cq
Greenhorn

Joined: Nov 13, 2000
Posts: 8
Are they same.
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
Hi Cq,

yes they are absolutely same.

regards
Deekasha
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
Cq as you are new to Javaranch i think I should point out that we have a naming policy which we enforce to mantain a professional atmosphere. Take a look here please and register again with a name that fits the rules.
Thanks


Pounding at a thick stone wall won't move it, sometimes, you need to step back to see the way around.
kirank
Greenhorn

Joined: Nov 14, 2000
Posts: 12
Yes, both of them are absolutly the same. Please refer to Java Laguage Specification (JLS) to see the syntax used in java.
String[]args or String args[] will create an array (reserves a place in memory)with no size and name args.
Sandeep Jain
Ranch Hand

Joined: Oct 25, 2000
Posts: 124
Yes they are the same.
You can decalre an array of string by either ways. Both will work fine.

------------------
Sandeep Jain


Try and Try Till u succeed<br /> <br />Sandeep Jain
Mike Brown
Greenhorn

Joined: Oct 19, 2003
Posts: 25
I'm glad he asked that question! I have been wondering that since I started studying Java. I have seen it both ways and both seem to work but I dodnt want to ask. Thanks cq!
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

Cq and Kirank:
Please do note that you should update your names to be in line with the naming policy as Angela mentioned. However, you do not need to re-register; simply update your display name to be in accordance with that policy.
Thanks,
Joel


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Steven Broadbent
Ranch Hand

Joined: Dec 10, 2002
Posts: 400
This form is preferred for declaring arrays:-

String [] x;
putting the [] after the name. Why? because it avoids subtle problems like this:-
String x [] , y; //x is an array but y is a String
String [] x y ; //two arrays


"....bigmouth strikes again, and I've got no right to take my place with the human race...."<p>SCJP 1.4
Yi Meng
Ranch Hand

Joined: May 07, 2003
Posts: 270
They are the same as in JLS
The [] may appear as part of the type at the beginning of the declaration, or as part of the declarator for a particular variable, or both, as in this example:
byte[] rowvector, colvector, matrix[];
This declaration is equivalent to:
byte rowvector[], colvector[], matrix[][];

The bottom line is that dun put [] before your variable, you may see the following legal:

But this line will fail:


Meng Yi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the difference between String[] args and String args[]