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.

3rd Sep 2017, 3:03 AM
Abhijeet Ranjan
Abhijeet Ranjan - avatar
6 ответов
+ 3
Look at the main method. Copy & paste it, and change the word "main".
3rd Sep 2017, 3:34 AM
Rrestoring faith
Rrestoring faith - avatar
+ 3
Methods have the following: (return type) (Name) (Parameters) SO: void myMethod(int a){} I suggest reviewing methods in the course.
3rd Sep 2017, 3:36 AM
Rrestoring faith
Rrestoring faith - avatar
+ 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.
3rd Sep 2017, 3:32 AM
Jordan Chapman
Jordan Chapman - avatar
+ 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
3rd Sep 2017, 4:34 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
- 1
hey bro pls give an example to make it clear. I am curious to see
3rd Sep 2017, 3:34 AM
Abhijeet Ranjan
Abhijeet Ranjan - avatar
- 1
if I am changing the word main then it says cannot find the main method...😥😥😥
3rd Sep 2017, 3:35 AM
Abhijeet Ranjan
Abhijeet Ranjan - avatar