TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Java Tutorials

Java Program Structure

Java Tutorial

Overview

This article explains the basic java program structure in detail. These key components make up the Java program. Let’s get started!

Java Program Structure

The components of a Java automation program that defines its structure are as below:

  • Javadoc comments
  • Package declaration
  • Import statements
  • Class declaration
  • Program code

 

Java Automation Program Structure

 

Javadoc comment

A Javadoc comment starts with a single forward slash and two asterisks (/**) and ends with an asterisk and one slash ( */ ). Each line of the comment starts with one asterisk:

/**
*This is a Javadoc comment
*/

Package declaration

A package is a directory or folder containing the class or interface.

A package declaration describes the folder in which it occurs. For example, the declaration

package com.testingdocs.javaautomation;

specifies that the class can be found in the directory com/testingdocs/javaautomation as shown below

Java package

 

Import statements

The import declaration can be used to make an entire package, or individual classes within a package, access to your Java program. Import statements, allow you to reference data and methods in other packages in your class.

Comments

Comments allow you to explain to others what you’re trying to do in your program code. You can have a single line comment or multi-line comment in Java. Note that when the program runs, comments are ignored.

//This is a single line comment

Multi-line comments

//This is a multi-line comment with
//two lines…..

Or

/*
This is a multi-line comment
explain about your code here……
*/

Automation code

Class is where you write your automation code logic. You can think of a class as a description of an object. It is a bundle of variables and methods that operate on them.

Java requires that each public class be in a separate file and that the file name is the class name with a .java extension. For example, AutomationHandler class must be in a file named AutomationHandler.java. As a convention, and good programming practice it is recommended to put every class in a separate file.

Read Input in Java Program

https://www.testingdocs.com/java-reading-from-standard-input/

–

Java Tutorials

Java Tutorial on this website:

https://www.testingdocs.com/java-tutorial/

For more information on Java, visit the official website :

https://www.oracle.com/java/

Related Posts

Download Greenfoot Windows

Java Tutorials /

Download & Install Greenfoot on Windows

Java Tutorials /

Java Static Code Analysis

Java Tutorials /

Java Testing Tools

Java Tutorials /

Handle Multiple Exceptions in Java

Exceptions_In_Java

Java Tutorials /

Exceptions in Java Programs

‹ Array of Objects in Java› Accessor and Mutator methods in Java

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version