- IntelliJ (IDE)
-
Create a new project in IntelliJ:
File
->New
->Project
. On the left, make sureJava
is selected, then clickNext
. Skip the next page, then name your project and set where the project is saved. -
Once your project loads, click the dropdown on your project folder. Right click the
src
folder and selectNew
->Java Class
. Name the fileHelloWorld
-
Write a method called
main
inside of yourHelloWorld
class. The body of the method should printHello World
onto the console when the program is run. You can run the program by clicking the green triangle next to your method.
Try it yourself before looking at these!
Code
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Console Output
Hello World
Process finished with exit code 0