What is a bug in this java code

Todo list online

have to go. Getting rid of jagged underlines from the editor is cause for celebration. Eclipse likes the look of your Java code, so it's smooth sailing from this point on. Law?

Well, that's not necessarily the case. In addition to some noticeable compile-time errors, your code may have other, less obvious errors.

Imagine someone telling you to “go to the intersection and then shut up.” You immediately notice that the speaker made a mistake and you respond politely, “Huh?” The nonsensical rurn tight phrase is like a compilation error. Your “Huh?” Is like the jagged underlines in the Eclipse editor. As a hearing person, you might be able to guess what rurn tight means, but Eclipse's editor never dares to fix the mistakes in your code.

In addition to compile-time errors, several other types of gremlins can hide in a Java program:

  • Unchecked runtime exceptions: You have no compilation errors, but if you run your program, the run will end prematurely. Somewhere in the middle of the run, your instructions are telling Java to do something it can't.

This is an example of an unchecked runtime exception - the equivalent of someone telling you to go right at the intersection when the only thing on the right is a large wall. Eclipse's editor does not warn you of an uncontrolled runtime exception because the computer cannot predict that the exception will occur until you run the program.

  • Logical errors: You won't see any error markers in Eclipse's editor, and when you run your code, the program will run to the full. But the answer is not correct. Let's say that instead of $ 552. 20, the output is $ 552,200,000.00. The program incorrectly tells you to pay what your home is worth thousands of times and tells you to pay that amount every month! It is the equivalent of being instructed to go right instead of going left. You can go the wrong way for a very long time.

Logic errors are the toughest errors to find and fix. And worst of all, logical mistakes often go unnoticed. In March 1985, a homeowner received a monthly heating bill for $ 1,328,932. 21. Of course, some computers had printed the wrong amount. When he called the gas company to complain about this, the operator said, "Don't be sad. Pay only half."

  • Compile time warnings: A warning is not as serious as an error message. So if Eclipse notices something suspicious in your program, the editor will show you a jagged yellow underline, a tiny yellow icon with an exclamation point, and a few other not-so-intrusive hints.

Imagine you should "turn at the intersection". "The direction may be good. But if you are suspicious, ask," Which way should I go? Left or right? "

When you are sure you know what you are doing, you can ignore warnings and deal with them later. But a warning can be an indicator that something more serious is wrong with your code. Comprehensive Recommendation: Pay attention to warnings. But if you can't figure out why you are getting a specific warning, don't let the warning stop you.