What is the correct way to reference Java members in text?

When answering questions, I found that I often mentioned method names and online documents I'm confused about how to reference method names in text

For example, I often type:

However, this is somewhat misleading:

>It makes equals () look like a static member. > It makes equals () seem to take no arguments

In order to complete, I want to know:

What is the correct way to reference static members and instance members?

I've seen words like this:

> String. equals() > String#equals() > myString. equals()

Is there any way to reference methods in a parameter independent manner?

For example, in C, foo (void) is explicitly a zero parameter function, and foo () can be redefined later to have different parameter sets (?)

Solution

If you want to be really accurate, you can use

java.lang.String#equals(java.lang.Object)

Or shorter form

String#equals(Object)

This is similar to the symbols used in Javadoc. Interestingly, it looks like a link to the document, ending in:

String.html#equals(java.lang.Object)

Edit: This is a link to how to use the referenced Javadoc documentation

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>