- Get link
- X
- Other Apps
Hello World In Java
In learning programming, it is a ritual to print Hello World! first😇. It is quite simple and interesting way to start learning a new language. In this section, we will write a simple java program,later on I'll give a detailed explanation of program.Lets start!
Notepad
Keeping it easy and simple. I want you to begin with notepad. As a beginner , you should know how to run java on your computer. So, we'll be creating first program in Notepad.
Steps:
- Open Notepad in you computer.You can search Notepad on Start.
- Create new file , Click File > New.
- Write the following program, as shown below, class is a keyword, it must be written in small letters.
- In the above program, we created a class named MyFirstProgram , this class contains a main method,which further contains print statement of java. You can understand each code statement in this detailed program explanation section.
- Save the file, Click File > Save/Save As OR Press CTRL +S >Type Name for file > Add .java Extension at the end of File name > Click Save. Your file name must be same as class name.
- Remember the location of the file where you have saved it. Now, Open Command Prompt, Click Start > Write cmd >Click on Command Prompt icon. Command prompt will get open.
- Now, to go to the Location using command in command prompt. cd.. command is used to go to previous folder or location, here cd is followed by two dots. It you want to go to next folders the use cd foldername .After writing each command press Enter, You can understand this having a look at following image.It shows the way to reach Desktop folder in computer.
- javac command is followed by your filename and .java extension. javac is java compiler. This command compiles the program.You must write the command correctly otherwise it will display errors.
- To execute java program java command is used. It is followed by file name only.Again use command correctly. Press Enter.Output of the program will appear.
Comments
Post a Comment
If you have any doubt, ask here