From the course: Java's Toughest Bugs

Overview of Java bugs - Java Tutorial

From the course: Java's Toughest Bugs

Overview of Java bugs

- [Instructor] Bugs in Java can manifest in various forms each with their unique set of challenges. Most of the time, they fit into one of two main categories, syntactical and logical. A syntax bug is an error caused by misusing the syntax of a given language. It means you entered a piece of code that the computer doesn't understand because it's not written in the proper format. You get this type of error when you leave out a semicolon or misspell a variable name. It causes your program to fail before it's even executed because the computer has to understand your code in order to run. Syntax bugs are the simplest types of bugs to fix because they often have a very clear error message with the line number pointing you to where the syntax is not correct. In this course, we'll be focusing more on logical bugs. These are errors where the program is able to run, but it doesn't act as the user expects. One example of this is a program providing some result that the programmer did not intend. Say, adding numbers instead of subtracting them. It could also be that certain exceptions get through with certain types of input. For example, if a given functions input is an empty string, maybe a null pointer exception or an index out of bound exception is thrown. With all other inputs, say the function works as expected, this means not all cases were covered during the original implementation, and there's a buggy case. The more complexity you add to your program, the more likely you'll have bugs, and it's impossible to plan for and prevent every type of bug that'll come up. The best thing you can do is attempt to mitigate the bug and fix it as soon as you notice it.

Contents