hello, I studied that java cant run without main method, but the following produce the output
How it is possible? Can you please tell about static also
Thank you in advance
Well, as you can see in the examples in this post, it is possible.
For some reason people ask this question now and then on the forums here: "how can I write a program that runs without a main() method", etc. I wonder why so many people are asking this (is there someone or some company who asks this to people as a trick question for job interviews?).
Anyway, it's an interesting but practically useless trick, I suggest you forget it immediately and never use it in any real program.