Designation of a non-static method

S

Stefan Ram

I used to think that it was common usage to use »C.f()« for
a static method »f()« and »C#f()« for a non-static method
»f()« of a class »C«.

Yet, in

http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html

, there is a reference »Random.nextDouble()« given
(at the end of the expanded documentation of »random()«),
that refers to the non-static method

http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#nextDouble()

. So is this now the official Java style to designate
even a non-static method »f()« of a class C by »C.f()«?
 
E

Eric Sosman

I used to think that it was common usage to use »C.f()« for
a static method »f()« and »C#f()« for a non-static method
»f()« of a class »C«.

Yet, in

http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html

, there is a reference »Random.nextDouble()« given
(at the end of the expanded documentation of »random()«),
that refers to the non-static method

http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#nextDouble()

. So is this now the official Java style to designate
even a non-static method »f()« of a class C by »C.f()«?

Don't fret about it.

"A foolish consistency is the hobgoblin of little minds,
adored by little statesmen and philosophers and divines."
-- RWE, "Self-Reliance"
 
L

Lew

Stefan said:
I used to think that it was common usage to use »C.f()« for
a static method »f()« and »C#f()« for a non-static method
»f()« of a class »C«.

AFAIK it still is.
Yet, in
http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html
, there is a reference »Random.nextDouble()« given
(at the end of the expanded documentation of »random()«),
that refers to the non-static method
http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#nextDouble()

. So is this now the official Java style to designate
even a non-static method »f()« of a class C by »C.f()«?

No.

Was it ever the official style to do it the common way?

I have not seen the "#/." convention universally employed, although I have observed
that it is common, particularly among more experienced and competent Java developers.

I have never seen it proffered as an official standard. Could you point to a reference
that it is or ever was?
 
J

Jan Burse

Stefan said:
I used to think that it was common usage to use »C.f()« for
a static method »f()« and »C#f()« for a non-static method
»f()« of a class »C«.
[Snip]

I find in the Java source code:

* @see Random#nextDouble()

I find in the HTML source code:

<a
href="../../java/util/Random.html#nextDouble()"><code>Random.nextDouble()</code></a>

I guess the HTML doc was generated via a doclet. The doclet
that was used for JDK 1.4 did already do the same transformation
of Java source code, into Java HTML javadoc. You can check for yourself:

http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html#random()

This has not changed since then for JDK 1.7:

http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#random()

Bye
 
J

Jan Burse

Hi,

For a java comment {@link Integer#MIN_VALUE} you also see
magically morph the hash (#) into a period (.).

This is all done by javadoc. The source of javadoc is open.
For example the see tag is defined here:

http://javasourcecode.org/html/open-source/jdk/jdk-6u23/com/sun/tools/javadoc/SeeTagImpl.java.html

The syntax of a @see tag is:

<where>#<what>

Whereby <where> is resolved into a ClassDoc or PackageDoc
and <what> is resolved into a MemberDoc.

Bye

Jan said:
Stefan said:
I used to think that it was common usage to use »C.f()« for
a static method »f()« and »C#f()« for a non-static method
»f()« of a class »C«.
[Snip]

I find in the Java source code:

* @see Random#nextDouble()

I find in the HTML source code:

<a
href="../../java/util/Random.html#nextDouble()"><code>Random.nextDouble()</code></a>


I guess the HTML doc was generated via a doclet. The doclet
that was used for JDK 1.4 did already do the same transformation
of Java source code, into Java HTML javadoc. You can check for yourself:

http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html#random()


This has not changed since then for JDK 1.7:

http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#random()

Bye
 
R

Roedy Green

I used to think that it was common usage to use »C.f()« for
a static method »f()« and »C#f()« for a non-static method
»f()« of a class »C«.

Random.nextDouble will not compile, but that is how the method is
named in JavaDoc. I suppose JavaDoc could be changed to generate
random.nextDouble to hint at the instanceness. On the other hand, you
will get a warning if you do someobject.somestatic().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,979
Messages
2,570,184
Members
46,721
Latest member
DollieSawt

Latest Threads

Top