Skip to main content


Welcome to `Basic Syntax` for Java beginners. This tutorial will teach you the correct format your code should be in as well as what some syntax related errors mean and how they may occur.

What is Syntax:
Syntax is the arrangement or format of your code. The way your code is laid out will not generally affect the performance of your program. However, if you have some in-correct syntax within your scripts this will cause a problem (most of the time it will cause a crash).

What Should Syntax Look Like?
In Java there are a few things to remember when thinking about Syntax:
- Java uses a line terminator (;) to end lines which are NOT; a statement, a loop, empty (including "{" or "}"), method/constructor top line.
- Braces are used to surround blocks of code ("{" and "}").
- Case Sensitive

Why is Good Syntax Important?
Syntax is a very important part of scripting. If you have the wrong syntax within your programs this can cause anything from a single minor problem to a major crash and quit.

Of course, if you have good syntax and very efficient scripting your program will complete it's tasks faster and run smoother where as having a ton of bad code will cause quite bad performance problems.

Good Syntax Example:
There are so many variations of how Syntax can be correct, but let's use the simple script from the first tutorial when we 'set up' the Java environment.

  1. public class Main {
  2. public static void main(String args[]) {
  3. System.out.println("Testing output.");
  4. }
  5. }

Bad Syntax Example:
Can you see where the two syntax errors are in the example below?

  1. Public Class Main {
  2. public static void main(String args[]) {
  3. System.out.println("Testing output.")
  4. }
  5. }

Spotted them yet? Remember the syntax rules, most lines must end with a terminator (;), braces are used to encase blocks and keywords are case sensitive!

The "Public Class" should not be capitalized and there is no terminator at the end of the console output line "System.out.println("Testing output.")".

Now that you know the syntax rules, you are ready to move on!

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.