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

    Java Performance

    Java Tutorials /

    Improving Java Performance with Multithreading

    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

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

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com