Lew <> wrote:
> Tom Anderson wrote:
>> Although the change could easily be backwards-compatible - permit main
>> to be void or int. I can't immediately see how it could break any
>> existing code.
> That would be a major change to the Java language, because it does not allow
> different return types for methods in the same class with otherwise identical
> signatures. The current main() signature suffices anyway.
It's not really all that major: You still cannot have two methods
with same parameter types and different return-value *at the same time in the
same class* (including "inherited" stuff). Though you can already have *any*
one such method. No one forbids you to define this one in absence of
conflicting variants:
public static int main(String[] args) {return 0;}
The question is, whether the jvm could/should make another try at
"int main(...)" after having failed for "void main(...)", or do some
reflection first to determine whether to call void main or int main
or byte main or long main or BigInteger main or ....
While I do think it quite easily *could*,
I personally do not think it *should*,
but would still likely use it if it did.