Learning Java Fundamentals: “Hello World”

Ifeoluwa Akinremi Wade
2 min readApr 17, 2022
Photo by Michiel Leunens on Unsplash

What is Java?

Java is an Object Oriented language. It is a popular programming language used for mobile apps (specifically Androids apps), web apps, desktop apps, games, web servers, application servers, database connection, etc.

Let’s Learn Some Java!

First and foremost, Java code is written in a class. The class name must match the file name the class is written in. For example, the file name is Main.java , therefore the class name will be Main .

public class Main {

}

We are going to print our first line in Java!

main Method

The main method is a required method in Java. Any code inside the this method will be executed — it is “an entry point to start the execution of a program” (Main Method in Java | public static void main(String[] args)). Every Java class will have at least one main method.

Hello World

I am going to add the code that will print out “Hello World” in the main method,

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

For a breakdown on the main method above, click here.

System.out.println()
This statement prints out the argument passed in.

System.out.println("Hello World"); // => Hello WorldSystem.out.println(3 + 3); // => 6

println()

Arguments passed in multiple println() — short for print line, get printed on a new line every time.

System.out.println("Hello " + "Ifeoluwa");System.out.println(5 + 5);// => Hello Ifeoluwa
// => 10

print()

Whereas arguments passed in multiple print() get printed on the same line.

System.out.print("Hello " + "Ifeoluwa");System.out.print(5 + 5);// => Hello Ifeoluwa10

NOTE: Each code statement must end with a semicolon (;)

--

--