Wednesday, March 26, 2014

Basic Java Tutorial For Beginners

Hello guys,

From today on-wards , i will be posting java tutorials on this blog. I will start with the real basics , kind of like a beginners tutorial, so that even the people who actually does not know java , can start learning.

So before we start , i suggest you to do a small search up on Google about the history of java technology.
Java is a "WORA" language, which means, "Write Once, Run Anywhere".
In other words, if you write a java program in Windows platform, you can run the same program in another platform (i.e:- Linux) without changing any part of the code.

Alright now before we get started , you should have an IDE installed in your machine to starting coding.
If you don't have an IDE , go to this  link to download Net beans IDE. 
Once you have the IDE , you have to download and install the "java run time environment" , which creates you the environment to program in java. To download "java run time environment", go to this link.

So lets get Started :-

Step 1 :- Launch Netbeans IDE.

Step 2:-  Click on File -> New Project -> Categories -> Java Application

Step 3:- Give a project name and a project location (Location where you want to save your program)

Step 4:- Untick "Create Main Class" and click "Finish"

Step 5:- Now on your projects tab (left upper corner), right click on the project which you have just created.

Step 6:- Click New -> "Java Class" -> Click Next -> Give any class name you like (But i suggest you to name it as Main for now, since my tutorial class will be called "Main") and Click Finish

You have just created a java class and now you can start coding.

Below is a basic java code,which displays a message called "Hello World".
Type in the below code just the way it is, in to the class you made and then press "F6" to compile and run the code.

Example Code:-





If everything goes well, you should be able to see the out.

Below is an example output:-



That's it , you have made your first java program, CONGRATS.
Well this is the most basic java code, next time ill be posting a code , which will take an input from the user and print it on to the screen, so stay tuned.
So until next time, good bye and take-care.

Thank you for reading this post, if you have questions, please post it down below.

Have a great day!

Note :-
"System.out.println("Your text goes here");" method is used to print text,numbers etc on to the screen.

The sentences starting with the symbols "//" are called comments. They are used to describe the purpose of the code or the algorithm used in the code.


No comments:

Post a Comment