What is the Java way to say in a text that a function belongs to a specific class?

For example, when writing a C++ commit message, I say

TimeInterval::toString() now uses a UTC timezone

I.e., I utilize :: to designate the toString() as a method of TimeInterval.

Is there a similar convention for Java?

closed as primarily opinion-based by gnat, Greg Burghardt, Andy, Jörg W Mittag, Becuzz Sep 6 '18 at 15:01

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    The symbols used are not "a convention", they correspond to the syntax of the language. – Doc Brown Sep 6 '18 at 14:37
  • You sometimes see a hash symbol to separate members, especially for instance methods: TimeInterval#toString(), or #toString() without the class. See the javadoc @see tag. – amon Sep 6 '18 at 15:16
  • The Oracle docs seem to use a dot (.): e.g., Date.toLocaleString(). – Alexander Pozdneev Sep 6 '18 at 20:58
  • Java 8 started to use a double colon (::) to reference methods, e.g., reduce(Math::max). – Alexander Pozdneev Sep 22 '18 at 13:24

Sure. You use the same period that you use in code:

The method TimeInterval.toString() returns a...

  • could also use method reference which would be TimeInterval::toString (no parens) but I think this would be rarer to see in documentation – jk. Sep 6 '18 at 15:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.