What are the pitfalls of a Java noob? [closed]
Solution 1:
There's a collection of semi-official "gotchas", known as the Java Puzzlers, and documented in a book of the same name; you might also find a few screencasts on the web. Periodically, Joshua Bloch and Neal Gafter like to present a bunch of innocuous-looking challenges and proceed to systematically remove any notion you had that you understood even the vaguest basics of the Java language.
On a slightly less cynical note, if you're looking to avoid many of the common design and implementation cock-ups, you might take a look at Effective Java, by the aforementioned Joshua Bloch, which has a wealth of decent advice on how to go about designing several of the important - but frequently badly written - aspects of writing components in Java, including a comprehensive explanation of how to properly implement the contract of equals()
and hashCode()
, and why you should avoid clone()
like the plague.
Oh, and don't compare strings with the ==
operator.
Solution 2:
Saying that objects are passed by reference.
Actually, methods work only with copies of object references..which are passed by value.
Java only works with pass by value.
Also worth reading: Is-java-pass-by-reference?
Solution 3:
A small one: searching for a Java class on Google and expecting to find up to date information. Advice: always include the version number i.e search "inputstream 6" not "inputstream". Similarly, beware of tutorials on the net, lot of them are outdated.
Solution 4:
Bookmark javadocs: http://java.sun.com/javase/6/docs/api/index.html
Better yet, install them locally and bookmark the page on your local machine for faster lookup and offline browsing.