Java

First JAVA Program for beginners

In order to start with basic Java programming, let us look at the standard first program. Download JAVA

First JAVA program

As you can see, the program uses a single line of code in the main() function, which prints
the statement ‘Hi javalessions.com’.

Print “Hi javalessions.com” by JAVA program

However, before that can be done, let us look at the steps that you must follow in your quest to execute the file.

  • Open any text editor and paste this code in that file.
  • Save the file with a .java extension. For example, you can save the file as Sample.java.
  • The next step is to to open the command prompt of the system and relocate its reference to the directory in which the file is saved.
  • For instance, if you have saved the file in C:\, then you must take the prompt to the same directory.
  • In order to compile the code, you must type the following: javac Sample.java If there are no errors, you will automatically be taken to the next line.
  • You can now execute the code using the following command: java Sample.java You should be able to see the following output on the screen.

“Hi javalessions.com”

Click here to know about JAVA

Leave a Reply

Your email address will not be published.

Back To Top