Home / Programming Language / JAVA programming / Java Programming Tutorial Part 3 : Creating First Program

Java Programming Tutorial Part 3 : Creating First Program

Hello everyone, welcome to our regular Java programming tutorial. This is our third tutorial going on. Previously, we have learned about Java and how to make a environment to do java programming on your PC. If you are new then you can check it from our previous tutorials.

First Java Programme
First Java Programme

Java Programming Tutorial Part 3 : Creating First Program

So, for now let us start our third tutorial. This will be about creating our first java program. Here we will learn how to create a java project file using NetBeans and then run it.

Programme Setup :

So, as we have already set up our IDE (NetBeans) now open the netbeans IDE. After opening the application on your device you will see the interface of your netbeans IDE. Now click on the “File” which you will find the left top side of your IDE Interface.

After clicking on the file go to ” new project ” or tap (Ctrl+Shift+N) from your keyboard. After that a new window will be opened. First select Java and click next. Another page will be there. You have to set up your project name. And also there will be a option for selecting folder where you want to keep your project files. But for now let’s see what are the naming rules for a java application.

Rules for naming java project,classes and variables :

There are many rules for creating a java project, classes and variables. We will learn them in future. It is not necessary to remember them all. But you can go and check the documentation from oracle for the naming : https://docs.oracle.com/javase/tutorial/

Writing the first java project:

So, now let give a name our java project. Lets name it “HelloWorld” – Why I do not put any space between the Hello and World. That because java do not support spaces when naming. That is why we have used a technique called camel case. Where we will use capital letter when we will start a new word.

After giving the name click finish. It will take a few time to create the project. After finishing the project creation there will be an interface like the image below:

Creating First Java Code
Creating First Java Code

So in the left side you can find you project. There you can also see the class file under the project folder. Basically we write all the java code into our .java class file. We have our code editor opened in the right side of our screen. We have to write our code inside the main class. only the code which will be inside the main class will be execute by the compiler and we will get out result.

Now write a code inside the main section. Our code will show the “hello World” in the Screen. Very simple code :

public class HelloWorld{
public static void main(String args[]){
    System. out. print("Hello Java");
   }
}

This System.print Statement is saying the compiler to print a line which will print hello World. So if we use print Statement and there Whatever we will write inside the quotation sign the exact thing will be shown in the display.

To see the result click on ” Shift+F6″ you can see the result showing below your code which is saying “Hello World”

So using the same logic lets create another programme which will print your name and phone number.

So, Create another class file under the same hello world project. For doing that right click on the project name and select > New > java class file.

Then another window will be opened and and now name your class file using same method. Lets name it as “CrystalBio” and click finish.

now inside the main section just write two line :

System. out. print("Name : Crystal");
System. out. print("Phone : 0000000000");

If you hit ” Shift+F6″ or run file you can see It’s showing Name And phone number side by side. Now you may have question in mind that we wrote them in different line but why the are in side by side. So the ans. is simple. we have wrote the code in different line. but we didn’t tell the programme that you should be in different line. For doing that there is another statement for the java and which is “println” If we use “println” instead of using ” print” it will print the different two line.

So, We are now done with our simple code. We will talk about Escape sequence in our next part. So for now thank you see you in next part.

Thank you for reading this post. If you are also ambitious to write blogs and want to improve your writing skills then create an account to this site and start writing new posts. You can also generate traffique for your site by writing your site’s post and link . See the rules of writing new post to know more.Also if you have any Question about this post or anything then comment below or mail me.

0%

User Rating: Be the first one !

Report this post if contains any Adult Content or Plagiarism :

About Md. Sabbir Al Mamon

I am Md.Sabbir Al Mamon. Now I'm studying CSE in BRAC University.

Leave a Reply