Introduction to Object Oriented Programming (OOP) with Java

Mark Crowe

mark.crowe@lit.ie

The Hello World Example

package ie.lit.learningjava;

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

Line 1: Defines the name of a package. Package names are by convention lowercase. they have no spaces.

Line 3: Defines the name of a the class. Class names are by convention Title case.

Lines 4 - 9: The braces define the body of the class. All the code inside the braces are part of this class.

Line 5: Defines the signature of a method. A Java program requires at least one class with a method with this signature.

Lines 6 - 8: The braces define the body of the method. All the code inside the braces are part of the method.

Line 7: This line of code prints out "Hello World" to the console.

Hello World.

The Bare Minimum Application

This application does nothing, but it is a application that you can run.

package ie.lit.learningjava;

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