Java 零碎


Javadoc

<img src="doc-files/uml.png" alt="UML diagram"/>
Create sub dir `doc-files` in src dir
    /src/com/mypackage/hello.java
    /src/com/mypackage/doc-files/

javadoc -d docDirectory nameOfPackage
javadoc -d docDirectory nameOfPackage1 nameOfPackage2...

If your files are in the default package, run instead
javadoc -d docDirectory *.java

javadoc -link http://docs.oracle.com/javase/7/docs/api *.java
all standard library classes are automatically linked to the documentation on the Oracle web site.

-linksource

Java instanceof

Use instanceof to check before casting from a superclass to a subclass.

if (staff[1] instanceof Manager)
{
    boss = (Manager) staff[1];
. . .
}

pg 221

If x.equals(y) is true, then x.hashCode() must return the same value as y.hashCode().

panda /
Published under (CC) BY-NC-SA in categories java  tagged with java