Java Reference
In-Depth Information
}
protected void doLogic() {
System.out.println("Subclass doLogic");
}
public static void main(String[] args) {
Derived dev = new Derived();
try {
// Has type Derived, as expected
Base devClone = (Base)dev.clone();
devClone.doLogic(); // Prints "Subclass doLogic"
// as expected
} catch (CloneNotSupportedException e) { /* ... */ }
}
}
Applicability
Failing to call super.clone() may cause a cloned object to have the wrong type.
Bibliography
[API 2013]
Class Object
62. Use comments consistently and in a readable fashion
Mixingtheuseoftraditionalorblockcomments(startingwith /* andendingwith */ )and
end-of-line comments (from // to the end of the line) can lead to misleading and confus-
ing code, which may result in errors.
Noncompliant Code Example
The following noncompliant code examples show mixed comments that may be misun-
derstood.
Click here to view code image
// */
/* Comment, not syntax error */
f = g/**//h;
/* Equivalent to f = g / h; */
/*//*/ l();
/* Equivalent to l(); */
m = n//**/o
+ p;
/* Equivalent to m = n + p; */
Search WWH ::




Custom Search