About Java entry points

What is an entry point?

The place where the program starts executing, which is the ** first method called . A method is executed in the flow of calling a method from a method and then calling the next method. The method called first among them is called the entry point ( starting point **). In Java, the main method is set as the entry point for the entire program (the main method is also used as the entry point in multiple languages such as C, C ++, and Objective-C). So it seems good to remember ** entry point = main method ** in Java. The routine that contains the entry point of the entire program is called the main routine, and the class that contains the main method is the main routine.

5 conditions of main method

In Java, rules such as modifiers, names, and arguments used in the main method are strictly defined.

** 1. Access modifier is public 2. static method 3. The return value of the method is void 4. Method name is main (lowercase) 5. Method arguments are only String arrays (or String variadic [^ 1]) **

Also, there is a rule that Java methods must ** always belong to some class.

The general main method based on the above conditions is as follows.

main.java


class Main {

    public static void main (String[] args) { 
        //processing
    }
}

By the way, the common argument "args" is the abbreviation of the arguments that represent the arguments.

Also, if the above ** 5 conditions are not met as shown below, it will not be recognized as the main method **.

**-A string type array is not passed as an argument -Passing another argument other than the String type array -The method name is not main ・ Do not use public, static, or void ** etc

Reference site:

The following sites have been very educational. There is also a more detailed explanation of the main method. [Main method indispensable for Java execution, explanation from its mechanism](https://engineer-club.jp/java-main#:~:text=Java%E3%81%AEmain%E3%83%A1 % E3% 82% BD% E3% 83% 83% E3% 83% 89% E3% 81% AF,% E3% 82% AC% E3% 83% 83% E3% 83% 81% E3% 83% AA% E6% B1% BA% E3% 82% 81% E3% 82% 89% E3% 82% 8C% E3% 81% A6% E3% 81% 84% E3% 81% BE% E3% 81% 99% E3% 80% 82)

[^ 1]: ... An argument whose number is indefinite (variable).

Recommended Posts

About Java entry points
About Java interface
[Java] About Java 12 features
[Java] About arrays
Something about java
Where about java
About Java features
About Java threads
[Java] About interface
About Java class
About Java arrays
About java inheritance
About interface, java interface
About java var
About Java literals
About Java commands
About Java functional interface
Java, about 2D arrays
About class division (Java)
About [Java] [StreamAPI] allMatch ()
[Java] About Singleton Class
[Java] About anonymous classes
[Java Silver] About initialization
About Java Array List
About Java Polymorphism super ()
About inheritance (Java Silver)
About Java String class
About Java access modifiers
About Java 10 Docker support
Personal summary about Java
All about Java programming
About java abstract class
A note about Java GC
What I researched about Java 8
About an instance of java
What I researched about Java 6
[Gradle] About Java plug-in tasks
About Java variable declaration statements
What I researched about Java 9
[Java] About try-catch exception handling
About Java class loader types
[Java Silver] About equals method
[Java] About String and StringBuilder
What I researched about Java 7
About Alibaba Java Coding Guidelines
About Java class variables class methods
About Java Packages and imports
About abstract classes in java
[Android / Java] Learned about DataBinding
What I researched about Java 5
About Java static and non-static methods
How about TECH ACADEMY ?? [Java course]
About fastqc of Biocontainers and Java
[Java] Points to note with Arrays.asList ()
[Introduction to Java] About Stream API
Learn about transaction savepoints (with Java)
[Java beginner] About abstraction and interface
About signature authentication with java 1st
About the current development environment (Java 8)
AtCoder 400 points algorithm summary (Java edition)
Java