General advice
1. As a beginner, read an introductory book on Java, there really is no better or faster way to learn the basics. Make sure to get a book that considers your existing skills (have you programmed before, have you done object-oriented programming before). Take a look at the reader comments sections of online book shops, they are often revealing. Note that nobody becomes a Java expert in a week, ten days or 21 days (read Peter Norvig's article Teach Yourself Programming in Ten Years for more on that topic).
2. To get some practice as a beginner, write small programs. If you are more experienced, try something larger (if you have no idea what to write, take a look at this list of student Java projects). It's not a good idea to write larger programs right from the beginning, although these are more interesting and challenging (e.g. games). Learn the basics first, read Jon Skeet's "Learning Java in stages" for an explanation.
3. If you have to do an assignment for a programming course, Patricia Shanahan's "So, You Need to Write a Program but Don't Know How to Start" might give you a few ideas.
4. The most important online resource is Sun's Java site. They defined the language, they offer specialized Java libraries (e. g. for 3D graphics, access to serial ports or email), tutorials, a bug database (where you can find out if errors that you experienced are known already) and more.
5. For answers to frequently asked questions check out Peter van der Linden's Java FAQ and Roedy Green's Java Glossary. Apart from the more advanced tips, they both also list solutions for typical Java problems (gotchas): FAQ, Glossary. Also see The Java IAQ: Infrequently Answered Questions. You might prefer to read an FAQ list in your language, e.g. the FAQ of the German newsgroup de.comp.lang.java. However, these Q&A lists are no replacement for learning the basics from a Java book or course.
6. Gain best practice knowledge from browsing the articles at Collected Java Practices. Various Java code examples are at Réal Gagnon's Java HowTo site. and Javaa! JavaFAQ.nu.
7. Get the latest stable Java Development Kit (JDK, sometimes SDK or JSDK) for your platform (most people will use those from Sun). Beta versions of JDKs often contain errors, so get them only if you want to check out new features that you plan to use in the future. Make sure that you have a copy of the HTML API documentation as well—it shows you which classes are available and what methods and fields they offer. If the downloads are too large for you (JDK + docs are more than 50 MB), check out the CD-ROMs that come with computer magazines—they might contain what you want and save you some download costs. Note that an end user who wants to run your program only needs a Java Runtime Environment (JRE), not a JDK. JREs are typically much smaller (Sun's JREs are around 10 MB).
8. Make use of packages (sets of related classes) to get some structure into your Java project (java.util is an example for a predefined package). You could have a package for data classes, one for I/O, one for GUI code etc. Jon Skeet explains in "Packages - A set of rules to keep your compiler happy" how compiling and running code with packages is done.
9. Try to create cross-platform code, no hardcoding of directories, line-feeds etc. Download Sun's JavaPureCheck tool. It lets you find out if your code is 100 percent Java and you can check if your code is compatible with any given Java version (e.g. 1.1). This is helpful to test compatibility with versions other than the one you yourself are developing with. There seem to be problems with using that no longer supported tool with more recent JDKs.
10. While you're programming, always have a webbrowser open with the API docs of the Java runtime classes. Nobody can memorize the exact syntax of all of those classes.
11. Try to stick to code conventions, e.g. those defined by Sun. Others are linked to at DMOZ. They define how code is to be formatted, give recommendations for naming variables, what characters are to be used for indentation etc. This makes the source code more readable, especially if several people work on the same project. You may want to use a code beautifier to automate the process.
12. Add meaningful comments to your code, don't comment on each and every self-explaining line of source code. On the other hand, comments should not be the only documentation of what your code does.
13. If you are writing a library, add small example programs to it. You may think that it's obvious how to use your library, but others could save a lot of time looking at the example code (and they will send you less mails asking for help).
14. Create backups of your code and all related files (documentation etc.). Follow the Tao of Backup (coverage, frequency, separation, history, testing, security and integrity). Automate the process. Use something like CVS.
15. Have a copy of the Java Language Specification available. View it on-line, download it or get the paper version.
16. Make use of newsgroups if you can't solve your problems. Try comp.lang.java.programmer or a local group, especially if you prefer your native language (e.g. de.comp.lang.java in German). Pick the right newsgroup, if your question is about AWT or Swing and if there is a newsgroup like comp.lang.java.gui, post there. Don't crosspost (= send the same message to several newsgroups) unless you really think it fits into several groups; in that case, specify a followup-to group. Check older newsposting by searching a Usenet archive like Google Groups. Before you post to a group, read some of the recent messages to get a feeling for the type of discussion (also see Eric Raymond's "How to Ask Questions the Smart Way"). Don't expect people to do your homework for you. Don't send a big chunk of Java code and simply ask why it doesn't work. Read the FAQ for the group so that the group members do not have to answer the same things over and over again. Learn about the rules of Usenet (the groups are no chatrooms; things like real names, good quoting style etc. have proven themselves over the years). Try to give something back by answering questions yourself.
17. Other Java online resources can be found browsing directories like the Open Directory or Yahoo.
18. Note that there are other steps in a software development cycle than just coding (= writing Java source code). Learn about requirements engineering, design, quality assurance etc. Take a look at other programming languages to learn what's good in Java and what's missing. Java isn't the right tool for all possible tasks.
Read more here:
http://schmidt.devlib.org/java/introduction.htmlI found these tips very useful so use them at your advantage :)