Hello World program


Hello World program

🙋 Need help? Ask an expert now!

If you have studied Java prior to today, you may have encountered the "Hello World!" program, which shows a basic illustration of the program printing words on the console. Let's take a look at this program below and run it to see what happens. Feel free to alter the text enclosed by the quotation marks to change the output.

package exlcode;

public class HelloWorldExample {
  // This is the main method
  public static void main(String[] args) {
    // This prints Hello World!
    System.out.println("Hello World!");

This program is comprised of two primary features:

  1. Class Definition - the keyword class begins the class definition for a class named name. The code for each class goes between the opening and closing braces. The class name format is UpperCamelCase, meaning the first letter of every word is capitalized and there are no spaces between the words.
  2. Main Method - Every application must contain a class that has been declared the main method with signature public static void main(String[] args). We will dive further into declaring methods, and terms such as public, static and void as we move further along. For now, remember how to declare a main method.

Special Note: A vital aspect of syntax to keep in mind as we move forward is that every statement must end in a semi-colon (;), as you see above in our Hello World example.

Edit Me on GitHub!

Application Question

Which of the following code segments produces the output "Java"?