Skip to content

kal01aki/Basic-Structure-of-Java-Program

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

JavaBasic-Structure-of-Java-Program

public class Main

        this creates a class called Main\.
        all class names must start with a capital letter\.
        the public word means that it is accessible from any other classes\.

---|---

comments

the compiler ignores comment block. comment can be used anywhere in the program to add info about the program or code block, which will be helpful for developers to understand the existing code in the future easily.

braces

two curly brackets {...} are used to group all the commands, so it is known that the commands belong to that class or method.

public static void main

        when the main method is declared public, it means that it can also be used by code outside of its class, due to which the main method is declared public\.
        the word static used when we want to access a method without creating its object,  as we call the main method, before creating any class objects\.
        the word void indicates that a method does not return a value\. main\(\) is declared as void because it does not return a value\.
        main is a method; this is a starting point of a java program\.

     you will notice that the main method code has been moved to some spaces left\. it is called indentation which used to make a program easier to read and understand\.

string[] args

it is an array where each element of it is a string, which has been named as "args". if your java program is run through the console, you can pass the input parameter, and main() method takes it as input.

system.out.println();

| this statement is used to print text on the screen as output, where the system is a predefined class, and out is an object of the printwriter class defined in the system. the method println prints the text on the screen with a new line. you can also use print() method instead of println() method. all java statement ends with a semicolon.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages