1. Hello World

www.freepik.com

In this lesson, we're gonna learn how to write main method and write a hello world app


In java we write our codes in the java classes
And every java class should have a main method
Main method is simply a code block, that executed first start of a java program.


First we need setup java on pc, because java runs on java virtual machine
You can download java from here

Then we need an IDE, a code editor for java
In this website, you can look at many different IDE'S and after you can download any ide you want
I'm using Intellij idea community edition for java coding.
You can download it from here


Writing your first program

After you download java and an ide for java, you should create java files in your ide. After you create a java file, this file should have a class with same name as your file.

for example, first.java should have a class like this
"public class first {}"
You can see end of the class, there is "{" and "}" symbols
In this symbols, we are gonna write our codes

So, in the curly brackets, we write this code
public class first{
public static void main(String[] args) {
System.out.println("Hello World");
}
}

After run our code, the output should be "Hello World"

Home Page
Next Lesson -> Variables
First Photo from www.freepik.com
>
Burakhan Ünver