3 ms·
So how this works is interesting. I assumed they were just making any method called 'main' sugar for public static void. But it's not that way. Instead, appar
by Gunax 3y ago
So how this works is interesting.
I assumed they were just making any method called 'main' sugar for public static void.
But it's not that way. Instead, apparently the proposal is to allow for main to be an instance method.
Additionally, we are getting anonymous classes.
Because methods can share names (both between inheritance and with different args) we apparently get a warning if a superclass also has a static main being overridden with an instance main. I would have preferred if this was simply an error.
- Traubenfuchs 3y ago> the proposal is to allow for main to be an instance method An instance method of... which instance? Is some invisible, nameless class instantiated with its default constructor? How would you acquire this main method via reflection?
- kaba0 3y agoImagine `public class [randomName] {` at the top. If it has a void main() method the class loader (not the spec!) will do new [randomName].main() You won’t acquire this main via reflection because why would you do so? It is for teaching, and one-off scripts. Later on you can trivially add that single line and name your class.