In answering questions I find myself referring to method names and online documentation often. I'm confused about how method names should be referenced in text.
For example I often type:
One should use
String.equals()
for comparing two strings for equality.
However, this is a little misleading:
equals()
appear to be a static member.equals()
appear to not take any arguments.In the interest of compleness, I would like to know:
What is the correct way to refer to both static members and instance members?
I've seen things like:
Is there a way to refer to methods in an argument-agnostic manner?
For example, in C foo(void)
is explicitly a zero-argument function and foo()
can be redefined later to have a different set of arguments. (?)
If you want to be really be exact you could use
java.lang.String#equals(java.lang.Object)
or the shorter form
String#equals(Object)
This is similar to the notation used in javadoc and interestingly also looks similar to the link to the documentation which ends with:
String.html#equals(java.lang.Object)
Edit: Here is a link to the javadoc documentation describing how to use references.
I've found that a link to the documentation for String's equals
method removes the ambiguity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With