Lecture 1: Java Basics – Hello World

Our first program will be to print something to the console, the classic Hello World program. Unlike Python Java is a Compiled Language, which means that the program needs to be compiled into binary for the computer to actually read the human-written code. Let’s start by developing the main entry point of Java:

class Main {
  public static void main(String[] args) {
    // This is the main entry point
  }
}

To break down this code we, first create a class called Main :

class Main {
 
}

Inside this class that we created, we create a main method which will be the entry point of our program. To put this into human terms you can call this the “key” to start the engine, every Java project has a main method in order for something to launch:

 public static void main(String[] args) {
   
  }

Let’s break down the syntax of this main method since it is one of the most important features in Java in order for the program to compile and run:

public – TODO
static – TODO
void– TODO
main(String[] args) - TODO

Furthermore, we placed a comment inside the main method which isn’t interpreted by the programming language as a reference to the programmer:

 // This is the main entry point

Let’s replace the comment inside the main method with the following code:

System.out.print("Hello World!"); 

Altogether, we should have the following:

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

Run the program and you should see a result similar to the following below:

> Hello World!

Congratulations on writing your first Java Hello World program!