Introduction
Here's a list of common problems you can encounter when programming in Java. Anyone else can feel free to add to this list. I'll try to update this "table of contents" when I can. Do not post in this topic requesting help with a problem you have.
Compile-time Problems
This category will cover a variety of problems with compiling your code. On compile, you will immediately be notified of these errors. They are fairly easy to find and fix.
- Parenthesis, Brackets, Braces, etc. mis-match
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-problems.html#post18614
- Type Mismatch/Invalid Cast
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-mistakes-post28215.html#post28215
- Abstract method in non-abstract class
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-problems.html#post18617
- Code outside of a method
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-mistakes.html#post18621
- Referencing Non-static variables/methods in a static way
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-mistakes.html#post18632
- Case sensitivity, spelling
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-mistakes.html#post18678
Common Run-time errors
This section is for common problems you could encounter at run-time. These problems usually are the direct cause of a crash. In general, these problems are a little more difficult to find, and may or may not be easy to fix.
- Forgetting to initialize a variable
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-mistakes.html#post18688
- Out of Memory Error
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-mistakes-2.html#post20021
- JDBC Connection Error: Class Not Found Exception
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-mistakes-2.html#post20626
Logic problems
This section is for common problems with logic. These problems usually result in the outputs being wrong, which in turn could crash another part of your program, though they do not need to (in fact, the ones that don't crash are the most difficult to find and fix). These can be very difficult to find and are also the hardest to fix even when you find the problem. You are probably better off putting a post inside the appropriate forum category (Again, do not post in this topic requesting help for specific problems you are having).
- == operator or equals() method
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-mistakes.html#post18725
- Array Indices/Off by 1 errors
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-mistakes.html#post19009
- byte/char/integer/long values wrapping around
- Permanent link: http://www.javaprogrammingforums.com/java-code-snippets-tutorials/5518-common-java-mistakes-2.html#post23822
Contributing to this list
Please follow the template outlined in this post.