当前位置:网站首页>Why do I need the public static void main (string[] args) method?
Why do I need the public static void main (string[] args) method?
2022-06-11 14:29:00 【Xiaoxi coding】
Why public static void main(String[ ] args) This method ?
public static void main(String[ ]args) by Java The entry method to the program ,JVM When running a program , Will look for main() Method . among ,public It's a permission modifier , Indicate any · Classes or objects can access this method ,static indicate main() Method is a static method , That is, the code in the method is stored in the static storage area , As long as the class is loaded , You can use this method without having to instantiate an object to access , You can use the class name directly .main() Direct access ,JVM Follow the above method when signing at startup ( There has to be public And static modification , The return value is void, Method when the parameter is a string array ) To find the entry address of the method , If you can find , Is executed ; Can't find , May be an error .void Indicates that the method has no return value ,main yes JVM The name of the special method recognized , Is the entry method of the program . String array parameters args It provides a means for developers to interact with programs in the command-line state .
because main Is the program waiting for the entry method , So when the program runs , The first way to do it is main() Method . Generally speaking , To execute a method of a class , First you must instantiate an object of a class , Then call this method through the object . But because of main Is the entry method of the program , The object has not been instantiated yet , So I'm writing main() Method requires that this method can be called without instantiating the object , In view of this ,main() Methods need to be defined as public And static. The following shows how to main() Method is the method of passing parameters .
public class T
边栏推荐
- In depth research and analysis report on global and Chinese SURFBOARD WAX Market
- Single table query of SQL data query
- Individual income tax rate table
- 高通WLAN框架学习(29)-- 6GHz 概述
- Current situation and future development trend of metal organic chemical vapor deposition (MOCVD) market in the world and China from 2022 to 2028
- In depth research and analysis report on global and Chinese liquid malt extract products market
- Leetcode 1962. Remove stones to minimize the total amount (should be rounded up)
- CVPR 2022 | 神经辐射场几何编辑方法NeRF-Editing
- 小米9线刷ROM
- airtest自动化测试
猜你喜欢

Chip engineers are too expensive? Your sister

Precision alignment adjustment platform

Two small things, feel the gap with the great God

.NET C#基础(6):命名空间 - 有名字的作用域

111. minimum depth of binary tree

How to quickly make the title and ending with one click?

Three level classification display

Cartoon: interesting "cake cutting" problem

Leetcode 1968. Construct an array whose elements are not equal to the average value of two adjacent elements (yes, finally solved)

强大的全文本搜索工具——AnyTXT Searcher
随机推荐
Invalid bound statement (not found) error [resolved]
【clickhouse专栏】新建库角色用户初始化
How to quickly compress the size of video?
IC fresh Chinese cabbage price of 400000 yuan! Experienced experts who have worked for many years guide you how to choose an offer!
线程池的七个参数与拒绝策略
In depth research and analysis report on global and Chinese oleoresin product market
Seven parameters of thread pool and reject policy
Extracting storage is the best memory method
In depth research and analysis report on global and Chinese hydrogen fuel station market
Is bone conduction earphone good for bone? Is bone conduction earphone harmful to the body?
浙江大学搞出了一款无人机,自动规避障碍,像鸟一样穿过树林,真正的蜂群来了...
Just after the college entrance examination, I was confused and didn't know what to do? Tell me what I think
Leetcode 1968. 构造元素不等于两相邻元素平均值的数组(可以,终于解决)
tf. Data (II) -- parallelization tf data. Dataset generator
Question bank and answers for 2022 tool fitter (intermediate) operation certificate examination
In depth research and analysis report on global and Chinese spray drying machinery market
Which exchange is PTA futures on? How can PTA futures be safe?
How to manage the server to make the website stable and smooth
Webgl programming guide learning (0)
Leetcode 1962. 移除石子使总数最小(应该是向上取整)