Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

7 ways of declaring main in java

  1. Jul 22, 2005 #1

    i know there are 7 ways to declare main in java

    1.public static void main(String args[])
    2.static public void main(String args[])

    but what are the other ways?

    but only change first two keywords
    i.e. public and static
    and use the required keywords.

    this is the question given to me.
  2. jcsd
  3. Jul 22, 2005 #2
    Apparently you can declare main() as private or protected, too. The code will compile, but you'll get an error when you run the program saying main() isn't public. I didn't know that. Also, I don't think you can remove "static" as you'll get an error when you try to compile if you do. Why do you want to declare main() in different ways anyway?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook