Difference between revisions of "Personal notes from when I was learning Java"
From Nick Jenkins
m (Reverted edits by 74.208.11.169 (Talk); changed back to last version by Nickj) |
|
(One intermediate revision by one user not shown) | |
(No difference)
|
Latest revision as of 05:37, 15 November 2007
- All objects point to the same thing, so be sure to use Object.clone() when you do not want to modify the original object.
- The "clone()" interface sucks for custom objects. Use a custom "duplicate()" function instead, which cannot throw an exception.
- Casting is a pain (feels very verbose if you are used to loosely-typed languages)
- The operator "+" is undefined for class Integer. That's right, kids, this is invalid syntax:
Integer i = new Integer(5); i = i + 2;
- An integer that you cannot add to with the 'plus' operator. Useful, huh?
- You need
hashCode
andequals
methods for all sorts of things, and if you don't implement these you'll get unexpected bugs. As such, a static analysis tool (like "findbugs") is absolutely essential.