0
methods
why cant we define the method name and definition inside the main function and use it and execute ...
3 Respostas
+ 2
We can't use method definaion in main. You should know the purpose of method is to reuse the method code anytime. According to the rules of syntax, we must define the method outside the main.
+ 1
in c++, method has an another name called member function. it has to be defined inside of class and it can be reused by the instances of that class. otherwise it's going to throw a syntax error.
+ 1
Java does not support nested methods. However, there are indirect ways to write a method in a method: https://www.google.de/amp/s/www.geeksforgeeks.org/method-within-method-in-java/amp/