Quantcast
Channel: User Federico klez Culloca - Stack Overflow
Viewing all articles
Browse latest Browse all 505

Answer by Federico klez Culloca for What happens if the first letter of a method in a java program is a capital / upper case letter?

$
0
0

Method names don't have to start with a lower case letter. It's just a shared convention so all developers are on the same page and people reading your code don't have to add extra cognitive load to quickly parse it.

Method names are case-sensitive, though. So if, for any reason, a name is expected to have a certain case it has to be respected.

One example is methods that need to be implemented because they are declared in an interface or abstract class (if the method you have to implement is called doStuff you can't implement it as DoStuff or dostuff).

Another example is the main method, which is the method the JVM expects to call when you run a class. It has to maintain the same case (and the fact that it has to be public, static, void and have an array of strings as its only argument), so you can't call it Main or MaiN. But that is a requirement of the JVM, not of the language.


Viewing all articles
Browse latest Browse all 505

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>