Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

main declaration

 
deepesh mathur
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry
the second statement public static void main(String[] args) is recmonded by sun.
 
Fu Dong Jia
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am agree with venkat kaka !
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, note that as of Java 1.5, you can also declare main as "public static void main(String... args)".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic