Search code examples
javabluej

Why doesn't IDE BlueJ give me an error for invalid `main()` declaration?


In my college, I was taught Java using BlueJ and we were asked to write main() in the following manner (no string array present as parameter):

public static void main()
{
//code
}

This works in BlueJ but it doesn't work in other IDEs like Eclipse (using right now).

All over the internet and books (except college texts), I find main() declared as public static void main(String[] args) .

My doubts:

  • When is the first way of declaring main() valid?
  • If the first declaration is wrong, why isn't BlueJ giving an error?
  • Is BlueJ designed to handle this internally?
  • What is the actual use of the string array parameter?

Solution

  • BlueJ does not require THE main method we all know aka public static void main(String[] args) { } so BlueJ is seeing that as a regular static method that happens to be called main "coincidentally."