From the course: Learning Java 11

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Sample solution: Find the errors

Sample solution: Find the errors - Java Tutorial

From the course: Learning Java 11

Start my 1-month free trial

Sample solution: Find the errors

- [Instructor] Let's walk through how to find and solve errors in the Challenge program. From the previous lesson, we started off with this code. Our IDE should help us find any syntax errors, like a misspelled variable or missing parentheses or a missing curly bracket. On line 12, we see we're missing a semicolon. We have this red squiggly line and it says semicolon expected. So we'll add a semicolon to fix that error. Let's run the program and see what our output is. It says let's calculate the area of a triangle. Input the base of the triangle in inches. So we'll say three. We'll have the height be four. The area is four. Scrolling down, we see the area should be the base times height divided by two. Three times four is 12 divided by two is six but here it's saying the area is four. Let's add some breakpoints and see if we can tell what's going on. Let's add a breakpoint on line 19 so we can see the value of base after we input a value. We'll also add one on line 26 so we can see…

Contents