Complete Java masterclass for beginners -03 (First Steps)

Now we are going to create our First project. Open IDEA and press on create new project.



    Now click on next. Again click on next. We are unchecking Create project from template as we want to show you how to do the initial part manually.

 
Again click on next. Enter your project name. We are typing HelloWorld here. Remember, we should not use space in the project name.

 
 Now click on finish. Now this window will come to  you.


   Click on the left triangle of hello world. Now right click on src.


    Click on New . Click on Java Class. Now enter a name for this class. I am using main as the name for this class.


Now this window will popup:




We will start our work inside the curly braces. A Java file can have more than one classes. From those only one becomes the main class. The other classes are created to help the main class. To declare a class main, we have to do something extra on it. We have to write:

public static void main(String[] args) {
   
}

Inside the public class main{
}
So our code will look like this:
public class main {

    public static void main(String[] args) {



    }

}

There are some keywords like public static void main String [] args. We  will discuss about it later on this course.
Creating our first project
Now we are going to run our first program. We are going to print hello world and run it.
To print something in Java, we have to use these keywords,

System.out.println();

Now in this brackets, we are going to tell what does it going to show. If we want to  show the value of something, we just have to enter its name. If we want to print a string which will directly show in the console, we have to use (“ “) in it. The out keyword used here is used to tell the compiler that we are going to get an output. The print keyword is used to print the things. ln is used to make a new line after it. So finally if we want to print Hello World we have to write,
System.out.println("Hello World");

Inside the main class and the whole code will look like:

public class main {

    public static void main(String[] args) {

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



    }

}

Now right click and press run. It will show the output

Output:


Finally we have successfully printed our first program! Stay with us and learn more about java! 
Challenge:
Using the knowledge, now it's your turn to print your name. Happy Coding



Comments

Popular posts from this blog

Complete Java masterclass for beginners -10 (switch statement)

Complete Java masterclass for beginners -11 (for loop)

Complete Java masterclass for beginners -06 (Unicode System)