Writing your first executable program in Java

Let's start with our basic coding in this section. If we want to print something in our output, there is a command in Java called System.out.println(). This command will print the output in the console. Let's say we would like to print hello world, and when we run the following code, hello world will be printed in our output console:

Firstclass.java

So let's run the code. There are two methods to run the code:

  • Right-click on the filename in the Project Explorer, click on Run As, and select Java Application.
  • Or, we could click on the run icon given in the toolbar and click on OK on the Save and Launch window. The icon looks like this:

This will run our code and print our output. The following ...

Get Hands-On Automation Testing with Java for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.