Learning Java Fundamentals: “Hello World”

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 (;)

--

--

--

Pursuing a role in tech!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Team Norms: Villainous Contraptions

Our migration story to Android O

Interview with Steph Martin — Senior Data Insights Consultant and Southampton Data Platform &…

How you can Fix 503 Service Unavailable Mistake in WordPress

OOP basics: class vs instance attributes in Python3

The Stack That Helped Opendoor Buy and Sell Over $1B in Homes

What is .NET framework? Q&A .NET Core vs .NET framework

AZ-104: Azure Administrator Study Guide

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ifeoluwa Akinremi Wade

Ifeoluwa Akinremi Wade

Pursuing a role in tech!

More from Medium

JAVA- Beginners need to know

JAVA /Interface

Java, terminologies