Hello, World! (Java)

“Hello, World!” is the first program written by most programmers.

If you are anywhere from being a beginner to being more experienced in Java, and if you have Windows or Mac, I recommend installing Eclipse IDE here. If you do not have Windows or Mac, I recommend creating an account on Repl.it here.

Eclipse:

Once you download Eclipse, go to:

File–>New–>Java Project–>(Name the Project)–> FINISH.

Click File->New->Java Project

Then, right click on the file and click New–>Class–>(Name the Class).

Right click file-> New Class

When you name the class, be sure to not put any characters or numbers as the beginning of the name. Also, do not include any spaces in the name. Finally, select the public static void main(String [] args) option and press FINISH. Now you are all set! 🙂

Click –>Run, Run to run your program!

Here’s how it works:

Input:

// This is a comment in Java, it does not affect the program or its output
// System.out.println() is used to print something out in java and go to the next line
// Quotes are used to denote that we are printing out a string
// You must put semicolons at the end of each line (except for comments, of course)

System.out.println("Hello, World!");

Output:

Hello, World

In Java, only double quotes (” “) are allowed for Strings. Therefore if you want to print something along with double quotes in java, you would have to do this:

Input:

// print something out with double quotes in java
System.out.println("\"Hello, World!\"");

Output:

"Hello, World!"
Design a site like this with WordPress.com
Get started