java - MyType#myMethod() 中的 "#"是什么意思以及与 MyType.myMethod() 中的 "."的区别

标签 java syntax vocabulary

嗯,一切都在标题中......

我知道这两种形式都引用了该方法,但我看不到 # 添加到另一种形式的内容。

最佳答案

哈希字符 (#) 不是 Java 语言的一部分。

它在 javadoc 中有特殊用途。 specification

package.class#member is any valid program element name that is referenced -- a package, class, interface, constructor, method or field name -- except that the character ahead of the member name should be a hash character (#).

As stated, the hash character (#), rather than a dot (.) separates a member from its class. This enables the Javadoc tool to resolve ambiguities, since the dot also separates classes, nested classes, packages, and subpackages. However, the Javadoc tool is generally lenient and will properly parse a dot if you know there is no ambiguity, though it will print a warning.

该表示法不仅适用于方法,它适用于任何类型成员。它有助于消除完全限定类型名称中的歧义。

关于java - MyType#myMethod() 中的 "#"是什么意思以及与 MyType.myMethod() 中的 "."的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24354882/

相关文章:

java - 使用java SDK在TFS中将测试用例更新为通过/失败

java - 如何在 libgdx 中制作再次播放按钮?

c - 有没有办法使用相同的函数对不同列表结构中的同一字段执行操作?

perl - 你能解释一下 perl 中的上下文相关变量赋值吗

html - 邮寄地址的标记

java - Jackson:基于实现接口(interface)的对象身份序列化/反序列化

java - Java 中泛型的队列实现

bash - Bash 中的 bang dollar (!$) 是什么?

dictionary - 任何免费的英语-西类牙语单词数据库?

language-agnostic - 你如何保持你的程序词汇量?