What are the valid characters for a Java method name?

ε祈祈猫儿з 提交于 2019-12-03 13:11:24

Yes, method names and variable names are what's called "identifiers". Identifiers all share the same rules regarding accepted characters. Take a look at §3.8 from the Java Language Specification to find out exactly what an identifier may contain, and §6.2 for an explanation about how identifiers are used.

You might be surprised when having unusual characters for method, such as:

public void mój_brzuch_zacznie_burczeć()

and it works pretty nice. Take a look at this blog to see more fancy examples.

yes, you are right, the same rules are applied for functions.

From the Java Tutorial:

"Although a method name can be any legal identifier, code conventions restrict method names." http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!