Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 2
    If looking the same as C++ was so much important for Java, why did they for example change : to extends? And public static void main(String [ ] args) inside a class is quite different than int main(int argc, char **argv) outside of a class. Commented Jul 10, 2012 at 22:19
  • 2
    @svick One possibility: Java introduced interfaces and clearly they wanted to separate the two concepts (inheriting interfaces/classes) - with just one "keyword" that won't work. And "quite different"? It's the nearest possible mapping of it and so far I've never seen a c++ programmer have a problem understanding that the static main method is the entry point. Contrary to that having a class called Application or something whose constructor is used, is something that would look strange to most c++ programmers. Commented Jul 11, 2012 at 0:33
  • @svick int in c to void in java had to with how a return code from an application was generated - in java, its 0 unless System.exit(int) is invoked. The change of parameters has to do with how arrays of strings are passed in each language. Everything in java is in a class - there is no option to have it elsewhere. Changing : to extends is a matter of syntax and are essentially the same. All else is dictated by the language. Commented Jul 11, 2012 at 20:08
  • @MichaelT But all those are design decisions that make Java different from C++. So why would be keeping Java the same as C++ be important in the case of main(), when it apparently wasn't important enough in other cases. Commented Jul 11, 2012 at 20:32
  • @svick Except that it's perfectly ok to not return anything from main in C too and such trivialities would hardly confuse anyone anyhow. The point wasn't to recreate c++ and all its mistakes but only to make the programmer more at home. What do you think a C++ programmer will have an easier time reading: Java or objective-c code? What do you think will look more obvious to a C++ programmer a main method or a constructor of some class as entry point? Commented Jul 11, 2012 at 20:35