aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes main declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "main declaration" Watch "main declaration" New topic
Author

main declaration

deepesh mathur
Ranch Hand

Joined: Aug 13, 2007
Posts: 39
hey ranchers,
i want to ask that

public static void main(String Args[]){
and
public static void main(String[] Args){


what's the diffrence between the two???
and what for this change is done??
venkat kaka
Greenhorn

Joined: Sep 27, 2007
Posts: 10
hi,
i think there is no change in both of main statement it's all about declaration of string array the first one is recomonded by sun.


Thanks
venkat.
venkat kaka
Greenhorn

Joined: Sep 27, 2007
Posts: 10
sorry
the second statement public static void main(String[] args) is recmonded by sun.
Fu Dong Jia
Ranch Hand

Joined: May 23, 2007
Posts: 131
I am agree with venkat kaka !


who dare win!<br />SCJP5(94%)|SCWCD5(86%)|SCBCD(100%)|SCEA in progress
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14352
    
  22

In Java, if you declare an array variable, you can put the [] either before or after the variable name. These two are exactly the same:

The first form is the recommended form. The second form only exists because this is how you declare arrays in C and C++, and the Java language designers probably wanted to make Java easier to understand for C and C++ programmers.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
Also, note that as of Java 1.5, you can also declare main as "public static void main(String... args)".


SCJP 5.0
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: main declaration