Java Syntax

In the previous chapter, we created a Java file called Main.java, and we used the following code to print "Hello World" to the screen:

```java
public class Main {
  public static void main(String[] args) {
    System.out.println("Hello World");
  }
}

### Example explained

Every line of code that runs in Java must be inside a `class`. The class name should always start with an uppercase first letter. In our example, we named the class **Main**.

**Note:** Java is case-sensitive. `MyClass` and `myclass` would be treated as two completely different names.

The name of the Java file **must match** the class name. So if your class is called `Main`, the file must be saved as `Main.java`. This is because Java uses the class name to find and run your code. If the names don't match, Java will give an error and the program will not run.

When saving the file, save it using the class name and add `.java` to the end of the filename. To run the example above on your computer, make sure that Java is properly installed: Go to the [Get Started Chapter](https://www.w3schools.com/java/java_getstarted.asp) for how to install Java. The output should be: