- Create "javacode" directory in D: drive, so you will have D:\javacode directory. We will use this directory to place our Java source code.
- Run text editor. In this example, we use Notepad. For those of you who know Integrated Development Environment (IDE) such as Eclipse or NetBeans, we have not used the IDE at this time, because by using Notepad we will understand the basic techniques of Java programming.
- Write the following code in it:
/* This is Java code. File of this code should be saved with the name HelloWorld.java. */ public class HelloWorld { //Execution of the program will be started by calling main(). public static void main(String[] args) { //Print Hello World to the console. System.out.println("Hello World"); } }
- Save with the name HelloWorld.java
Now, let's see more about the program code above. Although it looks a little (only consists of a few lines of code), the above program has several key features that common and is applied to all Java programs. First, the above program begins with the following code:
/* This is Java code. File of this code should be saved with the name HelloWorld.java. */
The above code is a program comment. Program comment is part of a program that will not be translated during the compilation process. The presence of the program comment is only used to provide the required information and will not affect the course of the program. Programmers usually use comment to write down the information about the code: when created, when modified, whom the author, and the most common is to write a logical process (algorithm) of the code created. Java provides three ways to write program comment: using sign /*..*/, //, and /**..*/. Comment that preceded by /* and end in */ may consist of a few lines, while starting with // will only apply to a single line. In code above we can see comment that has only one line, that is:
//Execution of the program will be started by calling main().and
//Print Hello World to the console.
The third type of comment (started with /** and end with */) are used to create documentation of using javadoc program.
The next line is as follows:
public class HelloWorld {
Line of code above using the class keyword to define a new class and followed by the name of the class. In Java, all programs are classes. Opening curly brackets, {, is used to initiate a program block, while the closing curly brackets, }, used to end a program block. Program block can be any class, method, selection structure, repetition structure, and so on. In this time, we do not discuss about the presence of public keyword contained in the code line. We will review it later in the next chapter that talks about package and interface.
Next, the HelloWorld class contained the following line of code:
public static void main(String[] args) {
The above line would start main() method. The main() method is the primary method to be executed first time when the program starts. If you ever learn C or C++ language, main() method contained in Java will be the same as the function of main() contained in C or C ++.
The next line of the code above is as follows:
System.out.println("Hello World");
The code used to display the "Hello World" text to the console.
Lastly, the above code is closed with closing curly brackets sign, }. The sign is used as the final part of the HelloWorld class definition.
Compile and Run
To compile and run a program that we made, we need to use command line via Command Prompt. The steps are as follows:
- Open Command Prompt, and go to our Java code directory in D:\javacode.
- Perform compile a file using the command javac HelloWorld.java.
If the compilation process runs smoothly without any errors, then system will not display anything in the console, but in that directory system will create a new file with the name HelloWorld.class. This file is called a bytecode and this file is the end file of program that we created.
-
To run or execute the program, type command java HelloWorld. System will display "Hello World" text to the console, as shown as follows:
Thank you for posting the valuable information about the java .And every people easily understand about your posting, and I am learning a lot of things from your posting,Keep it up.java classes
ReplyDelete
ReplyDeleteIt is nice article to improve my knowledge.thank you for sharing useful post
visit
web programming tutorial
welookups
Nice blog with excellent information. Thank you, keep sharing.ServiceNow Training in Hyderabad
ReplyDeleteThanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!
ReplyDeleteapple service center chennai | Mac service center in chennai | ipod service center in chennai | Apple laptop service center in chennai
Thank you so much for the valuable info
ReplyDeleteHere am sharing some information about Best Training Institutes java training in hyderabad |java course in hyderabad | java institutes in hyderabad | software training institutes in hyderabad |selenium training in hyderabad | software training institutes in hyderabad with placements |python training in hyderabad | python course in hyderabad | python institutes in hyderabad
Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
ReplyDeletetop servicenow online training
servicenow online training
best servicenow online training
ataşehir vestel klima servisi
ReplyDeletependik lg klima servisi
pendik alarko carrier klima servisi
pendik daikin klima servisi
tuzla toshiba klima servisi
tuzla beko klima servisi
çekmeköy lg klima servisi
beykoz toshiba klima servisi
üsküdar toshiba klima servisi
Thank you for sharing valuable information with us.
ReplyDeleteJava web application is a type of free programming language used to develop applications and software that are becoming highly in demand on the internet. The software engineer can provide the web application or software in the form of windows, Linux, and MAC OS. There are various types of systems that can not work without java and it is getting necessary day by day even the world’s no.1 application depends on java. Java has become a most popular feature in android smartphone applications that's why Aptech learning provides java training in Dwarka, Janakpuri, and in Gurgaon also. Java training helps to get you complete knowledge about web frameworks, Java testing tools, and design patterns in java.
Let's get learn about the PHP training course
PHP is a type of programming language that is most commonly used in dynamic functions such as modifying, collecting, and deleting all types of databases It also helps to encrypt all types of data in the form of HTML and XML file. Aptech learning provides you with a complete PHP training course at a reasonable cost that will help you to grow more in the era of the software industry.
For more details please visit our website : Aptech Dwarka
Good content. You write beautiful things.
ReplyDeletekorsan taksi
taksi
mrbahis
hacklink
vbet
hacklink
mrbahis
vbet
sportsbet
çorum
ReplyDeleteantep
ısparta
hatay
mersin
MTQ
muş
ReplyDeletetokat
afyon
amasya
manisa
G5UY
https://saglamproxy.com
ReplyDeletemetin2 proxy
proxy satın al
knight online proxy
mobil proxy satın al
OUZ