Kareem Adams wrote:1 - One can't define a method inside main method. ~ Lesson learned
2 - One can't define a method inside another method. ~ Lesson learned
Here's a suggestion: don't make things more complicated than they have to be. Language designers would never describe your problem that way. Here's how they would write it:
1 - One can't define a method inside another method.
The "main" method is a method, just like any other method, as far as this rule is concerned. There's no need to mention it separately in its own rule. I know when you're trying to understand a concept you get different pieces of it at different times, and that's what you did there. You just need to go through the final step to simplify your understanding as far as possible.
This doesn't just apply when you're understanding a concept. It also applies when you're designing and writing code, and it's the same process. Often when you start designing something, you think you have to have A, and B, and C. But then you think about those things a bit and you realize they are all the same thing, you just came upon them in different contexts, and you really just have to have X. If you didn't go through that final step, you would end up with a lot of duplicated code, whereas a more experienced programmer would take your code and simplify it by removing a bunch of junk.
It's partly true that as you get more practice with reading and writing code, you'll be able to go through the simplifying process more easily. It's also true that some people are better at it than others are.