0
Can we describe a method with any name?
Pls guys help me to understand this.... if we can then...Pls write a full program in Java with a method which has any name (eg. hello, school, Tyre etc.) to exactly show that it'll work.
6 ответов
+ 3
Look at the main method.
Copy & paste it, and change the word "main".
+ 3
Methods have the following:
(return type) (Name) (Parameters)
SO:
void myMethod(int a){}
I suggest reviewing methods in the course.
+ 2
yes you can and I won't write an example, I'm lazy and not your mommy. You'll have to do things for yourself. you can easily Google the syntax for functions.
+ 1
main method is mandatory in every java program.....
it is the method which the JVM executes first....
you can create other methods (of any other name according to rules) and call them from the main method according to your need .
here's a code I had created without main method.
don’t worry it doesn't run
https://code.sololearn.com/c7tp6w5Bqdzw/?ref=app
- 1
hey bro pls give an example to make it clear. I am curious to see
- 1
if I am changing the word main then it says cannot find the main method...😥😥😥