Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Basics Using your New Tools Errors

Does anyone have a simplified definition for syntax error? I would also like to know a little about a Runtime error.

An short definition or example would be very helpful.

2 Answers

leogerber
leogerber
2,225 Points

A syntax error is when your code is in the wrong format. So the compiler does not know what you are trying to express. This often happens when you forget to enter something like a semicolon.

A runtime error happens when your program successfully compiled and when you run the program an error occurs. This can happen because the compiler can't know every detail that is known during the execution (runtime). The compiler for example can't know what precise data a user might enter.

if you violate java syntax, you will get syntax error; java says, "At the end of any statement there should be a semicolon", so if you have a statement with no semicolon at the end of it, you are violating the java syntax rule, so you the compiler will tell you have syntax error by highlighting it.